• Home
  • Raw
  • Download

Lines Matching full:drive

241  * motor of these drives causes system hangs on some PCI computers. drive
242 * 0 is the low bit (0x1), and drive 7 is the high bit (0x80). Bits are on if
243 * a drive is allowed.
303 #define UNIT(x) ((x) & 0x03) /* drive on fdc */
304 #define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */
305 /* reverse mapping from unit and fdc to drive */
354 * this struct defines the different floppy drive types.
361 CMOS drive type
362 | Maximum data rate supported by drive type
415 * types (e.g. 360kB diskette in 1.2MB drive, etc.). Bit 1 of 'stretch'
605 static inline bool drive_no_geom(int drive) in drive_no_geom() argument
607 return !current_type[drive] && !ITYPE(drive_state[drive].fd_device); in drive_no_geom()
611 static inline int fd_eject(int drive) in fd_eject() argument
672 static void __reschedule_timeout(int drive, const char *message) in __reschedule_timeout() argument
676 if (drive < 0 || drive >= N_DRIVE) { in __reschedule_timeout()
678 drive = 0; in __reschedule_timeout()
680 delay = drive_params[drive].timeout; in __reschedule_timeout()
683 if (drive_params[drive].flags & FD_DEBUG) in __reschedule_timeout()
688 static void reschedule_timeout(int drive, const char *message) in reschedule_timeout() argument
693 __reschedule_timeout(drive, message); in reschedule_timeout()
717 * 2. No floppy disk is in the drive. This is done in order to ensure that
718 * requests are quickly flushed in case there is no disk in the drive. It
720 * the drive.
726 * change line is set, this means either that no disk is in the drive, or
733 static int disk_change(int drive) in disk_change() argument
735 int fdc = FDC(drive); in disk_change()
737 if (time_before(jiffies, drive_state[drive].select_date + drive_params[drive].select_delay)) in disk_change()
739 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))) || in disk_change()
740 (fdc_state[fdc].dor & 3) != UNIT(drive) || fdc != FDC(drive)) { in disk_change()
741 DPRINT("probing disk change on unselected drive\n"); in disk_change()
742 DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive), in disk_change()
746 debug_dcl(drive_params[drive].flags, in disk_change()
747 "checking disk change line for drive %d\n", drive); in disk_change()
748 debug_dcl(drive_params[drive].flags, "jiffies=%lu\n", jiffies); in disk_change()
749 debug_dcl(drive_params[drive].flags, "disk change line=%x\n", in disk_change()
751 debug_dcl(drive_params[drive].flags, "flags=%lx\n", in disk_change()
752 drive_state[drive].flags); in disk_change()
754 if (drive_params[drive].flags & FD_BROKEN_DCL) in disk_change()
756 &drive_state[drive].flags); in disk_change()
757 if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) { in disk_change()
758 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in disk_change()
761 if (drive_state[drive].maxblock) /* mark it changed */ in disk_change()
763 &drive_state[drive].flags); in disk_change()
766 if (drive_state[drive].keep_data >= 0) { in disk_change()
767 if ((drive_params[drive].flags & FTD_MSG) && in disk_change()
768 current_type[drive] != NULL) in disk_change()
770 current_type[drive] = NULL; in disk_change()
771 floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1; in disk_change()
776 drive_state[drive].last_checked = jiffies; in disk_change()
777 clear_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in disk_change()
796 unsigned char drive; in set_dor() local
808 drive = REVDRIVE(fdc, unit); in set_dor()
809 debug_dcl(drive_params[drive].flags, in set_dor()
811 disk_change(drive); in set_dor()
818 drive = REVDRIVE(fdc, unit); in set_dor()
819 drive_state[drive].select_date = jiffies; in set_dor()
825 static void twaddle(int fdc, int drive) in twaddle() argument
827 if (drive_params[drive].select_delay) in twaddle()
829 fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(drive)), in twaddle()
832 drive_state[drive].select_date = jiffies; in twaddle()
841 int drive; in reset_fdc_info() local
847 for (drive = 0; drive < N_DRIVE; drive++) in reset_fdc_info()
848 if (FDC(drive) == fdc && in reset_fdc_info()
849 (mode || drive_state[drive].track != NEED_1_RECAL)) in reset_fdc_info()
850 drive_state[drive].track = NEED_2_RECAL; in reset_fdc_info()
854 * selects the fdc and drive, and enables the fdc's input/dma.
855 * Both current_drive and current_fdc are changed to match the new drive.
857 static void set_fdc(int drive) in set_fdc() argument
861 if (drive < 0 || drive >= N_DRIVE) { in set_fdc()
862 pr_info("bad drive value %d\n", drive); in set_fdc()
866 fdc = FDC(drive); in set_fdc()
881 current_drive = drive; in set_fdc()
887 * Both current_drive and current_fdc are changed to match the new drive.
889 static int lock_fdc(int drive) in lock_fdc() argument
900 reschedule_timeout(drive, "lock fdc"); in lock_fdc()
901 set_fdc(drive); in lock_fdc()
933 static void floppy_off(unsigned int drive) in floppy_off() argument
936 int fdc = FDC(drive); in floppy_off()
938 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive)))) in floppy_off()
941 del_timer(motor_off_timer + drive); in floppy_off()
945 if (drive_params[drive].rps) { in floppy_off()
946 delta = jiffies - drive_state[drive].first_read_date + HZ - in floppy_off()
947 drive_params[drive].spindown_offset; in floppy_off()
948 delta = ((delta * drive_params[drive].rps) % HZ) / drive_params[drive].rps; in floppy_off()
949 motor_off_timer[drive].expires = in floppy_off()
950 jiffies + drive_params[drive].spindown - delta; in floppy_off()
952 add_timer(motor_off_timer + drive); in floppy_off()
957 * stopping at current drive. This is done before any long operation, to
963 int drive; in scandrives() local
971 drive = (saved_drive + i + 1) % N_DRIVE; in scandrives()
972 if (drive_state[drive].fd_ref == 0 || drive_params[drive].select_delay != 0) in scandrives()
974 set_fdc(drive); in scandrives()
975 if (!(set_dor(current_fdc, ~3, UNIT(drive) | (0x10 << UNIT(drive))) & in scandrives()
976 (0x10 << UNIT(drive)))) in scandrives()
979 set_dor(current_fdc, ~(0x10 << UNIT(drive)), 0); in scandrives()
1021 /* this function makes sure that the disk stays in the drive during the
1279 static void fdc_specify(int fdc, int drive) in fdc_specify() argument
1308 output_byte(fdc, UNIT(drive)); in fdc_specify()
1325 srt = 16 - DIV_ROUND_UP(drive_params[drive].srt * scale_dtr / 1000, in fdc_specify()
1333 hlt = DIV_ROUND_UP(drive_params[drive].hlt * scale_dtr / 2, in fdc_specify()
1340 hut = DIV_ROUND_UP(drive_params[drive].hut * scale_dtr / 16, in fdc_specify()
1360 /* Set the FDC's data transfer rate on behalf of the specified drive.
1373 /* TODO: some FDC/drive combinations (C&T 82C711 with TEAC 1.2MB) in fdc_dtr()
1445 DPRINT("Drive is write protected\n"); in interpret_errors()
1567 static void check_wp(int fdc, int drive) in check_wp() argument
1569 if (test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) { in check_wp()
1572 output_byte(fdc, UNIT(drive)); in check_wp()
1577 clear_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in check_wp()
1579 &drive_state[drive].flags); in check_wp()
1580 debug_dcl(drive_params[drive].flags, in check_wp()
1582 debug_dcl(drive_params[drive].flags, "wp=%x\n", in check_wp()
1586 &drive_state[drive].flags); in check_wp()
1589 &drive_state[drive].flags); in check_wp()
1606 * the drive. in seek_floppy()
1663 * reached track 0. Probably no drive. Raise an in recal_interrupt()
1782 * Must do 4 FD_SENSEIs after reset because of ``drive polling''.
1882 /* avoid dma going to a random drive after shutdown */ in floppy_shutdown()
1908 /* no read since this drive is running */ in start_motor()
1942 * drive/controller combinations */ in floppy_ready()
2069 static int next_valid_format(int drive) in next_valid_format() argument
2073 probed_format = drive_state[drive].probed_format; in next_valid_format()
2076 !drive_params[drive].autodetect[probed_format]) { in next_valid_format()
2077 drive_state[drive].probed_format = 0; in next_valid_format()
2080 if (floppy_type[drive_params[drive].autodetect[probed_format]].sect) { in next_valid_format()
2081 drive_state[drive].probed_format = probed_format; in next_valid_format()
2107 static void set_floppy(int drive) in set_floppy() argument
2109 int type = ITYPE(drive_state[drive].fd_device); in set_floppy()
2114 _floppy = current_type[drive]; in set_floppy()
2224 static int do_format(int drive, struct format_descr *tmp_format_req) in do_format() argument
2228 if (lock_fdc(drive)) in do_format()
2231 set_floppy(drive); in do_format()
2259 unsigned int drive = (unsigned long)req->rq_disk->private_data; in floppy_end_request() local
2269 floppy_off(drive); in floppy_end_request()
2745 buffer_drive != current_drive || /* bad drive */ in make_raw_rw_request()
2800 pr_info("buffer drive=%d\n", buffer_drive); in make_raw_rw_request()
2859 int drive; in redo_fd_request() local
2879 drive = (long)current_req->rq_disk->private_data; in redo_fd_request()
2880 set_fdc(drive); in redo_fd_request()
2883 set_floppy(drive); in redo_fd_request()
3011 * Resets the FDC connected to drive <drive>.
3012 * Both current_drive and current_fdc are changed to match the new drive.
3014 static int user_reset_fdc(int drive, int arg, bool interruptible) in user_reset_fdc() argument
3018 if (lock_fdc(drive)) in user_reset_fdc()
3052 static const char *drive_name(int type, int drive) in drive_name() argument
3059 if (drive_params[drive].native_format) in drive_name()
3060 floppy = floppy_type + drive_params[drive].native_format; in drive_name()
3229 int drive; in raw_cmd_ioctl() local
3235 for (drive = 0; drive < N_DRIVE; drive++) { in raw_cmd_ioctl()
3236 if (FDC(drive) != current_fdc) in raw_cmd_ioctl()
3238 if (drive == current_drive) { in raw_cmd_ioctl()
3239 if (drive_state[drive].fd_ref > 1) { in raw_cmd_ioctl()
3243 } else if (drive_state[drive].fd_ref) { in raw_cmd_ioctl()
3276 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3285 if (lock_fdc(drive)) in floppy_raw_cmd_ioctl()
3287 set_floppy(drive); in floppy_raw_cmd_ioctl()
3297 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3316 int drive, int type, struct block_device *bdev) in set_geometry() argument
3327 g->track <= 0 || g->track > drive_params[drive].tracks >> STRETCH(g) || in set_geometry()
3335 if (lock_fdc(drive)) { in set_geometry()
3355 if (lock_fdc(drive)) in set_geometry()
3364 user_params[drive] = *g; in set_geometry()
3365 if (buffer_drive == drive) in set_geometry()
3366 SUPBOUND(buffer_max, user_params[drive].sect); in set_geometry()
3367 current_type[drive] = &user_params[drive]; in set_geometry()
3368 floppy_sizes[drive] = user_params[drive].size; in set_geometry()
3378 if (drive_state[current_drive].maxblock > user_params[drive].sect || in set_geometry()
3380 ((user_params[drive].sect ^ oldStretch) & in set_geometry()
3436 static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) in get_floppy_geometry() argument
3441 if (lock_fdc(drive)) in get_floppy_geometry()
3446 *g = current_type[drive]; in get_floppy_geometry()
3455 int drive = (long)bdev->bd_disk->private_data; in fd_getgeo() local
3456 int type = ITYPE(drive_state[drive].fd_device); in fd_getgeo()
3460 ret = get_floppy_geometry(drive, type, &g); in fd_getgeo()
3491 int drive = (long)bdev->bd_disk->private_data; in fd_locked_ioctl() local
3492 int type = ITYPE(drive_state[drive].fd_device); in fd_locked_ioctl()
3539 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3540 /* somebody else has this drive open */ in fd_locked_ioctl()
3542 if (lock_fdc(drive)) in fd_locked_ioctl()
3547 ret = fd_eject(UNIT(drive)); in fd_locked_ioctl()
3549 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3550 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3554 if (lock_fdc(drive)) in fd_locked_ioctl()
3556 current_type[drive] = NULL; in fd_locked_ioctl()
3557 floppy_sizes[drive] = MAX_DISK_SIZE << 1; in fd_locked_ioctl()
3558 drive_state[drive].keep_data = 0; in fd_locked_ioctl()
3562 return set_geometry(cmd, &inparam.g, drive, type, bdev); in fd_locked_ioctl()
3564 ret = get_floppy_geometry(drive, type, in fd_locked_ioctl()
3573 drive_params[drive].flags |= FTD_MSG; in fd_locked_ioctl()
3576 drive_params[drive].flags &= ~FTD_MSG; in fd_locked_ioctl()
3579 if (lock_fdc(drive)) in fd_locked_ioctl()
3583 ret = drive_state[drive].flags; in fd_locked_ioctl()
3591 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3593 return do_format(drive, &inparam.f); in fd_locked_ioctl()
3596 if (lock_fdc(drive)) in fd_locked_ioctl()
3600 drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f); in fd_locked_ioctl()
3603 outparam = &drive_params[drive].max_errors; in fd_locked_ioctl()
3606 drive_params[drive].max_errors = inparam.max_errors; in fd_locked_ioctl()
3609 outparam = drive_name(type, drive); in fd_locked_ioctl()
3616 drive_params[drive] = inparam.dp; in fd_locked_ioctl()
3619 outparam = &drive_params[drive]; in fd_locked_ioctl()
3622 if (lock_fdc(drive)) in fd_locked_ioctl()
3629 outparam = &drive_state[drive]; in fd_locked_ioctl()
3632 return user_reset_fdc(drive, (int)param, true); in fd_locked_ioctl()
3634 outparam = &fdc_state[FDC(drive)]; in fd_locked_ioctl()
3637 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in fd_locked_ioctl()
3640 outparam = &write_errors[drive]; in fd_locked_ioctl()
3643 return floppy_raw_cmd_ioctl(type, drive, cmd, (void __user *)param); in fd_locked_ioctl()
3645 if (lock_fdc(drive)) in fd_locked_ioctl()
3752 int drive, type; in compat_set_geometry() local
3766 drive = (long)bdev->bd_disk->private_data; in compat_set_geometry()
3767 type = ITYPE(drive_state[drive].fd_device); in compat_set_geometry()
3769 &v, drive, type, bdev); in compat_set_geometry()
3774 static int compat_get_prm(int drive, in compat_get_prm() argument
3783 err = get_floppy_geometry(drive, ITYPE(drive_state[drive].fd_device), in compat_get_prm()
3796 static int compat_setdrvprm(int drive, in compat_setdrvprm() argument
3808 drive_params[drive].cmos = v.cmos; in compat_setdrvprm()
3809 drive_params[drive].max_dtr = v.max_dtr; in compat_setdrvprm()
3810 drive_params[drive].hlt = v.hlt; in compat_setdrvprm()
3811 drive_params[drive].hut = v.hut; in compat_setdrvprm()
3812 drive_params[drive].srt = v.srt; in compat_setdrvprm()
3813 drive_params[drive].spinup = v.spinup; in compat_setdrvprm()
3814 drive_params[drive].spindown = v.spindown; in compat_setdrvprm()
3815 drive_params[drive].spindown_offset = v.spindown_offset; in compat_setdrvprm()
3816 drive_params[drive].select_delay = v.select_delay; in compat_setdrvprm()
3817 drive_params[drive].rps = v.rps; in compat_setdrvprm()
3818 drive_params[drive].tracks = v.tracks; in compat_setdrvprm()
3819 drive_params[drive].timeout = v.timeout; in compat_setdrvprm()
3820 drive_params[drive].interleave_sect = v.interleave_sect; in compat_setdrvprm()
3821 drive_params[drive].max_errors = v.max_errors; in compat_setdrvprm()
3822 drive_params[drive].flags = v.flags; in compat_setdrvprm()
3823 drive_params[drive].read_track = v.read_track; in compat_setdrvprm()
3824 memcpy(drive_params[drive].autodetect, v.autodetect, in compat_setdrvprm()
3826 drive_params[drive].checkfreq = v.checkfreq; in compat_setdrvprm()
3827 drive_params[drive].native_format = v.native_format; in compat_setdrvprm()
3832 static int compat_getdrvprm(int drive, in compat_getdrvprm() argument
3839 v.cmos = drive_params[drive].cmos; in compat_getdrvprm()
3840 v.max_dtr = drive_params[drive].max_dtr; in compat_getdrvprm()
3841 v.hlt = drive_params[drive].hlt; in compat_getdrvprm()
3842 v.hut = drive_params[drive].hut; in compat_getdrvprm()
3843 v.srt = drive_params[drive].srt; in compat_getdrvprm()
3844 v.spinup = drive_params[drive].spinup; in compat_getdrvprm()
3845 v.spindown = drive_params[drive].spindown; in compat_getdrvprm()
3846 v.spindown_offset = drive_params[drive].spindown_offset; in compat_getdrvprm()
3847 v.select_delay = drive_params[drive].select_delay; in compat_getdrvprm()
3848 v.rps = drive_params[drive].rps; in compat_getdrvprm()
3849 v.tracks = drive_params[drive].tracks; in compat_getdrvprm()
3850 v.timeout = drive_params[drive].timeout; in compat_getdrvprm()
3851 v.interleave_sect = drive_params[drive].interleave_sect; in compat_getdrvprm()
3852 v.max_errors = drive_params[drive].max_errors; in compat_getdrvprm()
3853 v.flags = drive_params[drive].flags; in compat_getdrvprm()
3854 v.read_track = drive_params[drive].read_track; in compat_getdrvprm()
3855 memcpy(v.autodetect, drive_params[drive].autodetect, in compat_getdrvprm()
3857 v.checkfreq = drive_params[drive].checkfreq; in compat_getdrvprm()
3858 v.native_format = drive_params[drive].native_format; in compat_getdrvprm()
3866 static int compat_getdrvstat(int drive, bool poll, in compat_getdrvstat() argument
3875 if (lock_fdc(drive)) in compat_getdrvstat()
3881 v.spinup_date = drive_state[drive].spinup_date; in compat_getdrvstat()
3882 v.select_date = drive_state[drive].select_date; in compat_getdrvstat()
3883 v.first_read_date = drive_state[drive].first_read_date; in compat_getdrvstat()
3884 v.probed_format = drive_state[drive].probed_format; in compat_getdrvstat()
3885 v.track = drive_state[drive].track; in compat_getdrvstat()
3886 v.maxblock = drive_state[drive].maxblock; in compat_getdrvstat()
3887 v.maxtrack = drive_state[drive].maxtrack; in compat_getdrvstat()
3888 v.generation = drive_state[drive].generation; in compat_getdrvstat()
3889 v.keep_data = drive_state[drive].keep_data; in compat_getdrvstat()
3890 v.fd_ref = drive_state[drive].fd_ref; in compat_getdrvstat()
3891 v.fd_device = drive_state[drive].fd_device; in compat_getdrvstat()
3892 v.last_checked = drive_state[drive].last_checked; in compat_getdrvstat()
3893 v.dmabuf = (uintptr_t) drive_state[drive].dmabuf; in compat_getdrvstat()
3894 v.bufblocks = drive_state[drive].bufblocks; in compat_getdrvstat()
3905 static int compat_getfdcstat(int drive, in compat_getfdcstat() argument
3912 v = fdc_state[FDC(drive)]; in compat_getfdcstat()
3934 static int compat_werrorget(int drive, in compat_werrorget() argument
3942 v = write_errors[drive]; in compat_werrorget()
3958 int drive = (long)bdev->bd_disk->private_data; in fd_compat_ioctl() local
3986 return compat_get_prm(drive, compat_ptr(param)); in fd_compat_ioctl()
3988 return compat_setdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3990 return compat_getdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3992 return compat_getdrvstat(drive, true, compat_ptr(param)); in fd_compat_ioctl()
3994 return compat_getdrvstat(drive, false, compat_ptr(param)); in fd_compat_ioctl()
3996 return compat_getfdcstat(drive, compat_ptr(param)); in fd_compat_ioctl()
3998 return compat_werrorget(drive, compat_ptr(param)); in fd_compat_ioctl()
4007 int drive; in config_types() local
4009 /* read drive info out of physical CMOS */ in config_types()
4010 drive = 0; in config_types()
4011 if (!drive_params[drive].cmos) in config_types()
4012 drive_params[drive].cmos = FLOPPY0_TYPE; in config_types()
4013 drive = 1; in config_types()
4014 if (!drive_params[drive].cmos) in config_types()
4015 drive_params[drive].cmos = FLOPPY1_TYPE; in config_types()
4017 /* FIXME: additional physical CMOS drive detection should go here */ in config_types()
4019 for (drive = 0; drive < N_DRIVE; drive++) { in config_types()
4020 unsigned int type = drive_params[drive].cmos; in config_types()
4029 allowed_drive_mask |= 1 << drive; in config_types()
4031 allowed_drive_mask &= ~(1 << drive); in config_types()
4043 pr_info("Floppy drive(s):"); in config_types()
4048 pr_cont("%s fd%d is %s", prepend, drive, name); in config_types()
4050 drive_params[drive] = *params; in config_types()
4059 int drive = (long)disk->private_data; in floppy_release() local
4063 if (!drive_state[drive].fd_ref--) { in floppy_release()
4065 drive_state[drive].fd_ref = 0; in floppy_release()
4067 if (!drive_state[drive].fd_ref) in floppy_release()
4068 opened_bdev[drive] = NULL; in floppy_release()
4076 * drive with different device numbers.
4080 int drive = (long)bdev->bd_disk->private_data; in floppy_open() local
4088 old_dev = drive_state[drive].fd_device; in floppy_open()
4089 if (opened_bdev[drive] && opened_bdev[drive] != bdev) in floppy_open()
4092 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) { in floppy_open()
4093 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_open()
4094 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in floppy_open()
4097 drive_state[drive].fd_ref++; in floppy_open()
4099 opened_bdev[drive] = bdev; in floppy_open()
4104 /* if opening an ED drive, reserve a big buffer, in floppy_open()
4106 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5)) in floppy_open()
4134 drive_state[drive].fd_device = new_dev; in floppy_open()
4135 set_capacity(disks[drive], floppy_sizes[new_dev]); in floppy_open()
4137 if (buffer_drive == drive) in floppy_open()
4141 if (fdc_state[FDC(drive)].rawcmd == 1) in floppy_open()
4142 fdc_state[FDC(drive)].rawcmd = 2; in floppy_open()
4146 drive_state[drive].last_checked = 0; in floppy_open()
4148 &drive_state[drive].flags); in floppy_open()
4151 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) in floppy_open()
4153 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) in floppy_open()
4158 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) in floppy_open()
4165 drive_state[drive].fd_ref--; in floppy_open()
4167 if (!drive_state[drive].fd_ref) in floppy_open()
4168 opened_bdev[drive] = NULL; in floppy_open()
4181 int drive = (long)disk->private_data; in floppy_check_events() local
4183 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4184 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) in floppy_check_events()
4187 if (time_after(jiffies, drive_state[drive].last_checked + drive_params[drive].checkfreq)) { in floppy_check_events()
4188 if (lock_fdc(drive)) in floppy_check_events()
4194 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4195 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_check_events()
4196 test_bit(drive, &fake_change) || in floppy_check_events()
4197 drive_no_geom(drive)) in floppy_check_events()
4205 * a disk in the drive, and whether that disk is writable.
4209 int drive; member
4216 int drive = cbdata->drive; in floppy_rb0_cb() local
4221 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); in floppy_rb0_cb()
4226 static int __floppy_read_block_0(struct block_device *bdev, int drive) in __floppy_read_block_0() argument
4239 cbdata.drive = drive; in __floppy_read_block_0()
4265 * there is a disk in the drive at all... Thus we also do it for fixed
4269 int drive = (long)disk->private_data; in floppy_revalidate() local
4273 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4274 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4275 test_bit(drive, &fake_change) || in floppy_revalidate()
4276 drive_no_geom(drive)) { in floppy_revalidate()
4281 res = lock_fdc(drive); in floppy_revalidate()
4284 cf = (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4285 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)); in floppy_revalidate()
4286 if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { in floppy_revalidate()
4290 drive_state[drive].maxblock = 0; in floppy_revalidate()
4291 drive_state[drive].maxtrack = 0; in floppy_revalidate()
4292 if (buffer_drive == drive) in floppy_revalidate()
4294 clear_bit(drive, &fake_change); in floppy_revalidate()
4295 clear_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_revalidate()
4297 drive_state[drive].generation++; in floppy_revalidate()
4298 if (drive_no_geom(drive)) { in floppy_revalidate()
4300 res = __floppy_read_block_0(opened_bdev[drive], drive); in floppy_revalidate()
4307 set_capacity(disk, floppy_sizes[drive_state[drive].fd_device]); in floppy_revalidate()
4451 DPRINT("bad drive for set_cmos\n"); in set_cmos()
4544 int drive; in floppy_cmos_show() local
4546 drive = p->id; in floppy_cmos_show()
4547 return sprintf(buf, "%X\n", drive_params[drive].cmos); in floppy_cmos_show()
4594 static bool floppy_available(int drive) in floppy_available() argument
4596 if (!(allowed_drive_mask & (1 << drive))) in floppy_available()
4598 if (fdc_state[FDC(drive)].version == FDC_NONE) in floppy_available()
4605 int drive = (*part & 3) | ((*part & 0x80) >> 5); in floppy_find() local
4606 if (drive >= N_DRIVE || !floppy_available(drive)) in floppy_find()
4611 return get_disk_and_module(disks[drive]); in floppy_find()
4616 int i, unit, drive, err; in do_floppy_init() local
4632 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4633 disks[drive] = alloc_disk(1); in do_floppy_init()
4634 if (!disks[drive]) { in do_floppy_init()
4639 disks[drive]->queue = blk_mq_init_sq_queue(&tag_sets[drive], in do_floppy_init()
4642 if (IS_ERR(disks[drive]->queue)) { in do_floppy_init()
4643 err = PTR_ERR(disks[drive]->queue); in do_floppy_init()
4644 disks[drive]->queue = NULL; in do_floppy_init()
4648 blk_queue_bounce_limit(disks[drive]->queue, BLK_BOUNCE_HIGH); in do_floppy_init()
4649 blk_queue_max_hw_sectors(disks[drive]->queue, 64); in do_floppy_init()
4650 disks[drive]->major = FLOPPY_MAJOR; in do_floppy_init()
4651 disks[drive]->first_minor = TOMINOR(drive); in do_floppy_init()
4652 disks[drive]->fops = &floppy_fops; in do_floppy_init()
4653 disks[drive]->events = DISK_EVENT_MEDIA_CHANGE; in do_floppy_init()
4654 sprintf(disks[drive]->disk_name, "fd%d", drive); in do_floppy_init()
4656 timer_setup(&motor_off_timer[drive], motor_off_callback, 0); in do_floppy_init()
4711 /* initialise drive state */ in do_floppy_init()
4712 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4713 memset(&drive_state[drive], 0, sizeof(drive_state[drive])); in do_floppy_init()
4714 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in do_floppy_init()
4715 set_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in do_floppy_init()
4716 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in do_floppy_init()
4717 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in do_floppy_init()
4718 drive_state[drive].fd_device = -1; in do_floppy_init()
4772 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4773 if (!floppy_available(drive)) in do_floppy_init()
4776 floppy_device[drive].name = floppy_device_name; in do_floppy_init()
4777 floppy_device[drive].id = drive; in do_floppy_init()
4778 floppy_device[drive].dev.release = floppy_device_release; in do_floppy_init()
4779 floppy_device[drive].dev.groups = floppy_dev_groups; in do_floppy_init()
4781 err = platform_device_register(&floppy_device[drive]); in do_floppy_init()
4786 disks[drive]->private_data = (void *)(long)drive; in do_floppy_init()
4787 disks[drive]->flags |= GENHD_FL_REMOVABLE; in do_floppy_init()
4788 device_add_disk(&floppy_device[drive].dev, disks[drive], NULL); in do_floppy_init()
4794 while (drive--) { in do_floppy_init()
4795 if (floppy_available(drive)) { in do_floppy_init()
4796 del_gendisk(disks[drive]); in do_floppy_init()
4797 platform_device_unregister(&floppy_device[drive]); in do_floppy_init()
4810 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4811 if (!disks[drive]) in do_floppy_init()
4813 if (disks[drive]->queue) { in do_floppy_init()
4814 del_timer_sync(&motor_off_timer[drive]); in do_floppy_init()
4815 blk_cleanup_queue(disks[drive]->queue); in do_floppy_init()
4816 disks[drive]->queue = NULL; in do_floppy_init()
4817 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4819 put_disk(disks[drive]); in do_floppy_init()
4955 int drive; in floppy_release_irq_and_dma() local
4983 for (drive = 0; drive < N_FDC * 4; drive++) in floppy_release_irq_and_dma()
4984 if (timer_pending(motor_off_timer + drive)) in floppy_release_irq_and_dma()
4985 pr_info("motor off timer %d still active\n", drive); in floppy_release_irq_and_dma()
5030 int drive; in floppy_module_exit() local
5038 for (drive = 0; drive < N_DRIVE; drive++) { in floppy_module_exit()
5039 del_timer_sync(&motor_off_timer[drive]); in floppy_module_exit()
5041 if (floppy_available(drive)) { in floppy_module_exit()
5042 del_gendisk(disks[drive]); in floppy_module_exit()
5043 platform_device_unregister(&floppy_device[drive]); in floppy_module_exit()
5045 blk_cleanup_queue(disks[drive]->queue); in floppy_module_exit()
5046 blk_mq_free_tag_set(&tag_sets[drive]); in floppy_module_exit()
5052 if (!(allowed_drive_mask & (1 << drive)) || in floppy_module_exit()
5053 fdc_state[FDC(drive)].version == FDC_NONE) in floppy_module_exit()
5054 disks[drive]->queue = NULL; in floppy_module_exit()
5056 put_disk(disks[drive]); in floppy_module_exit()