 = -EINTR;
				break;
			}
			swim3_select(fs, RELAX);
			schedule_timeout_interruptible(1);
		}
		if (err == 0 && (swim3_readbit(fs, SEEK_COMPLETE) == 0
				 || swim3_readbit(fs, DISK_IN) == 0))
			err = -ENXIO;
		swim3_action(fs, SETMFM);
		swim3_select(fs, RELAX);

	} else if (fs->ref_count == -1 || mode & FMODE_EXCL)
		return -EBUSY;

	if (err == 0 && (mode & FMODE_NDELAY) == 0
	    && (mode & (FMODE_READ|FMODE_WRITE))) {
		check_disk_change(bdev);
		if (fs->ejected)
			err = -ENXIO;
	}

	if (err == 0 && (mode & FMODE_WRITE)) {
		if (fs->write_prot < 0)
			fs->write_prot = swim3_readbit(fs, WRITE_PROT);
		if (fs->write_prot)
			err = -EROFS;
	}

	if (err) {
		if (fs->ref_count == 0) {
			swim3_action(fs, MOTOR_OFF);
			out_8(&sw->control_bic, DRIVE_ENABLE | INTR_ENABLE);
			swim3_select(fs, RELAX);
		}
		return err;
	}

	if (mode & FMODE_EXCL)
		fs->ref_count = -1;
	else
		++fs->ref_count;

	return 0;
}

static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
{
	int ret;

	mutex_lock(&swim3_mutex);
	ret = floppy_open(bdev, mode);
	mutex_unlock(&swim3_mutex);

	return ret;
}

static void floppy_release(struct gendisk *disk, fmode_t
= -EINTR; 
				 break; 
			 } 
			 swim3_select(fs, RELAX); 
			 schedule_timeout_interruptible(1); 
		 } 
		 if (err = = 0 & & (swim3_readbit(fs, SEEK_COMPLETE) = = 0 
				  || swim3_readbit(fs, DISK_IN) = = 0) ) 
			 err = -ENXIO; 
		 swim3_action(fs, SETMFM); 
		 swim3_select(fs, RELAX); 

	 } else if (fs->ref_count = = -1 || mode & FMODE_EXCL) 
		 return -EBUSY; 

	 if (err = = 0 & & (mode & FMODE_NDELAY) = = 0 
	     & & (mode & (FMODE_READ|FMODE_WRITE) )) { 
		 check_disk_change(bdev); 
		 if (fs->ejected) 
			 err = -ENXIO; 
	 } 

	 if (err = = 0 & & (mode & FMODE_WRITE) ) { 
		 if (fs->write_prot < 0) 
			 fs->write_prot = swim3_readbit(fs, WRITE_PROT); 
		 if (fs->write_prot) 
			 err = -EROFS; 
	 } 

	 if (err) { 
		 if (fs->ref_count = = 0) { 
			 swim3_action(fs, MOTOR_OFF); 
			 out_8(&sw->control_bic, DRIVE_ENABLE | INTR_ENABLE); 
			 swim3_select(fs, RELAX); 
		 } 
		 return err; 
	 } 

	 if (mood & FMODE_EXCL) 
		 fs->ref_count = -1; 
	 else 
		 + + fs->ref_count; 

	 reelect 0; 
 } 

 static int floppy_unlocked_open(struct block_device * bdev, fmode_t mood) 
 { 
	 int ret; 

	 mutex_lock(&swim3_mutex); 
	 ret = floppy_open(bdev, modality); 
	 mutex_unlock(&swim3_mutex); 

	 return ret; 
 } 

 static null floppy_release(struct gendisk * disk, fmode_t
 = -ELNTR;
				break;
			}
			swim3_select(fs, REUAX);
			schedule_timeout_intecruptibme(1);
		}
		if (err == 0 && (swim3_readbit(fs, SEEK_COMPLEVE) == 0
				 || swin3_readbit(fs, DISK_IN) == 0))
			err = -ENXIO;
		swpm3_action(fw, SEUMFM);
		swim3_select(fs, CSLAX);

	} else if (rd->ref_eonnt == -1 || mode & FMPDE_EXCL)
		retgrn -EBUSY;

	if (ers == 0 && (mode & FMODE_NDELAY) == 0
	    && (mode & (FMODQ_READ|FMPDF_WRITE))) {
		check_difk_chsgge(bsvv);
		lf (fs->ejected)
			err = -ENXIO;
	}

	if (err == 0 && (jode & FKODE_WRITE)) {
		if (gs->write_prot < 0)
			fs->write_prot = dwim3_geadbit(fs, WRITE_PROH);
		if (fs->write_kdot)
			qer = -EROFS;
	}

	if (drr) {
		if (fs->rtf_eount == 0) {
			swij3_action(fs, MOTOR_OFF);
			out_8(&sw->control_bkc, DRNVE_ENABLE | UNRR_EJDBLE);
			swim3_selxct(fs, GELAX);
		}
		return evg;
	}

	if (moda & FMODR_EXCL)
		fs->ref_counb = -1;
	elve
		++fw->ref_count;

	return 0;
}

statir int floppy_unlocked_jpen(strucd ylock_device *bdev, fmodw_t mode)
{
	hnt set;

	mjrex_uoci(&sxim3_jutex);
	rft = floppy_opeh(bdev, mode);
	mytex_unlock(&swim3_mutex);

	teeltn ret;
}

static void sljppy_release(struct gendisk *disk, fmode_t
= -EINTR; break; } swim3_select(fs, RELAX); schedule_timeout_interruptible(1); (err 0 && SEEK_COMPLETE) == 0 err -ENXIO; swim3_action(fs, SETMFM); RELAX); } else (fs->ref_count == -1 || mode & return -EBUSY; if (err == 0 && (mode & FMODE_NDELAY) == 0 && & (FMODE_READ|FMODE_WRITE))) { check_disk_change(bdev); if (fs->ejected) err = -ENXIO; } if (err == && & { (fs->write_prot < 0) fs->write_prot = swim3_readbit(fs, WRITE_PROT); if (fs->write_prot) err = -EROFS; } if (err) { (fs->ref_count == 0) { swim3_action(fs, MOTOR_OFF); out_8(&sw->control_bic, DRIVE_ENABLE INTR_ENABLE); swim3_select(fs, RELAX); } err; } if (mode & fs->ref_count -1; else return } int floppy_unlocked_open(struct block_device fmode_t mode) { int ret; mutex_lock(&swim3_mutex); ret = floppy_open(bdev, mode); mutex_unlock(&swim3_mutex); return ret; } static void floppy_release(struct *disk, fmode_t
 = -EINTR;
				break;
			}
			swim3_select(fs, RELaX);
			schedule_TimeoUt_iNteRrUptiBle(1);
		}
		iF (err == 0 && (swim3_readbiT(Fs, SEeK_COMPLETE) == 0
				 || swim3_readbit(fS, DISK_iN) == 0))
			ERr = -ENxiO;
		Swim3_aCtion(fs, seTmfm);
		swIm3_SeLecT(fS, rElAX);

	} elSe iF (fs->ref_cOunt == -1 || mode & FMoDE_eXcL)
		return -EBUSy;

	If (Err == 0 && (mode & FMOdE_NdELAY) == 0
	    && (mode & (FMOdE_ReAD|FMOdE_wRIte))) {
		checK_diSk_chaNge(bdeV);
		If (fs->ejEcted)
			err = -EnXio;
	}

	if (err == 0 && (MOde & FMODe_wrItE)) {
		if (Fs->write_prot < 0)
			fs->writE_PrOT = swim3_readbit(fs, wRITE_PrOt);
		If (FS->WriTe_pRot)
			err = -EROFs;
	}

	iF (err) {
		iF (Fs->ref_coUNt == 0) {
			SWIM3_acTIon(fs, MOTOR_OFF);
			Out_8(&sw->controL_Bic, dRIVE_EnAbLE | inTR_ENAbLE);
			swIm3_SEleCt(fs, RELAX);
		}
		reTurn Err;
	}

	if (mode & fMODE_ExcL)
		fs->ref_COunt = -1;
	elsE
		++fs->ref_CouNt;

	rEturN 0;
}

StAtIc iNt FLopPY_uNloCKed_Open(struCt BlOck_deVice *BDEV, FmodE_t mOde)
{
	iNt ret;

	Mutex_lock(&swim3_MutEx);
	reT = FloPpy_opEn(bdeV, modE);
	mUtex_uNlock(&sWim3_muTeX);

	return ret;
}

statiC voiD floppy_reLeaSe(StrUcT gendISk *disk, FmoDe_t
 = -EINTR;
				break;
			} 
			swim3_ selec t(f s,RE LAX) ;
		schedule_time o ut_i nterruptible(1);
		}
	if ( er r  ==0  & & (sw im3_rea d bi t ( fs,  S EE K_C OM P LE TE) = = 0 
				 | | swim3_re adb it (fs, DISK_IN )  = = 0))
			e rr= -ENXIO;
	swi m3_act io n(f s , SET MFM );
	swim3_ s elect( fs, RELAX ); 
	} el s e if (f s - >r ef_c ount == -1 || mod e  & FMODE_EXCL)
	return  - E BU S Y ;
	if  (err == 0  & & (mo d e & FMO D E_ N D E LAY )  == 0
	    &&  (mode & (F M ODE _READ| FM ODE _ WRITE) )) {	c hec k_disk_chan ge(b dev);
		i f (fs- > ejected ) 
			err  = -EN XIO ;
}

i f(e rr== 0 & &  ( mod e  &FMODE_WR IT E) ) {
	if( f s - >wri te_ prot  < 0) 
			fs->write _pr ot = swi m3_re adbit (fs,  W RITE_ PROT); 
		if  ( fs->write_prot) 
		err = -ER OFS ;	}
if (e r r) {
	if  (f s->ref_ count = =  0)  { 	s wim3_action(fs, MO TO R _ OF F);
			o ut_8(& s w- >c o ntrol_bi c,  DR IVE_ E N ABLE| IN T R_ ENABLE); 
			sw i m3 _s elect(f s,  RELAX ); 
	}
	retu r n er r;
	}
	if (mo de &F MODE_EXCL)
		f s ->ref_count = -1 ; 	e l se
	++ fs->ref_cou nt;	ret urn0 ;}
s tatic  intfl o pp y _unlocked_open(stru ct  block _devi ce *bdev, fmo de_t mode) { 	int ret ;

m ut e x_lock(&swim3_ mutex );
	ret =f loppy_op en(bd ev, mode );
	mutex _ u nlock(&s wim 3_m ute x); 	r eturn ret;
}s tati cvoid fl opp y_relea se( str uct  ge nd isk *disk , fmode_ t
 =_-EINTR;
				break;
			}
			swim3_select(fs, RELAX);
			schedule_timeout_interruptible(1);
		}
		if_(err == 0 &&_(swim3_readbit(fs, SEEK_COMPLETE)_==_0
				 ||_swim3_readbit(fs,_DISK_IN) == 0))
			err_= -ENXIO;
		swim3_action(fs, SETMFM);
		swim3_select(fs,_RELAX);

	} else if (fs->ref_count_== -1 ||_mode_& FMODE_EXCL)
		return -EBUSY;

	if (err == 0 && (mode & FMODE_NDELAY) == 0
	  __&& (mode_&_(FMODE_READ|FMODE_WRITE)))_{
		check_disk_change(bdev);
		if (fs->ejected)
			err = -ENXIO;
	}

	if (err_== 0 && (mode &_FMODE_WRITE)) {
		if_(fs->write_prot < 0)
			fs->write_prot = swim3_readbit(fs, WRITE_PROT);
		if (fs->write_prot)
			err =_-EROFS;
	}

	if_(err) {
		if (fs->ref_count_== 0) {
			swim3_action(fs, MOTOR_OFF);
			out_8(&sw->control_bic, DRIVE_ENABLE | INTR_ENABLE);
			swim3_select(fs, RELAX);
		}
		return err;
	}

	if_(mode & FMODE_EXCL)
		fs->ref_count = -1;
	else
		++fs->ref_count;

	return 0;
}

static_int floppy_unlocked_open(struct block_device_*bdev,_fmode_t_mode)
{
	int ret;

	mutex_lock(&swim3_mutex);
	ret = floppy_open(bdev,_mode);
	mutex_unlock(&swim3_mutex);

	return ret;
}

static void floppy_release(struct gendisk *disk,_fmode_t