Lines Matching full:drive
240 * motor of these drives causes system hangs on some PCI computers. drive
241 * 0 is the low bit (0x1), and drive 7 is the high bit (0x80). Bits are on if
242 * a drive is allowed.
302 #define UNIT(x) ((x) & 0x03) /* drive on fdc */
303 #define FDC(x) (((x) & 0x04) >> 2) /* fdc of drive */
304 /* reverse mapping from unit and fdc to drive */
353 * this struct defines the different floppy drive types.
360 CMOS drive type
361 | Maximum data rate supported by drive type
413 * types (e.g. 360kB diskette in 1.2MB drive, etc.). Bit 1 of 'stretch'
604 static inline bool drive_no_geom(int drive) in drive_no_geom() argument
606 return !current_type[drive] && !ITYPE(drive_state[drive].fd_device); in drive_no_geom()
610 static inline int fd_eject(int drive) in fd_eject() argument
671 static void __reschedule_timeout(int drive, const char *message) in __reschedule_timeout() argument
675 if (drive < 0 || drive >= N_DRIVE) { in __reschedule_timeout()
677 drive = 0; in __reschedule_timeout()
679 delay = drive_params[drive].timeout; in __reschedule_timeout()
682 if (drive_params[drive].flags & FD_DEBUG) in __reschedule_timeout()
687 static void reschedule_timeout(int drive, const char *message) in reschedule_timeout() argument
692 __reschedule_timeout(drive, message); in reschedule_timeout()
716 * 2. No floppy disk is in the drive. This is done in order to ensure that
717 * requests are quickly flushed in case there is no disk in the drive. It
719 * the drive.
725 * change line is set, this means either that no disk is in the drive, or
732 static int disk_change(int drive) in disk_change() argument
734 int fdc = FDC(drive); in disk_change()
736 if (time_before(jiffies, drive_state[drive].select_date + drive_params[drive].select_delay)) in disk_change()
738 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive))) || in disk_change()
739 (fdc_state[fdc].dor & 3) != UNIT(drive) || fdc != FDC(drive)) { in disk_change()
740 DPRINT("probing disk change on unselected drive\n"); in disk_change()
741 DPRINT("drive=%d fdc=%d dor=%x\n", drive, FDC(drive), in disk_change()
745 debug_dcl(drive_params[drive].flags, in disk_change()
746 "checking disk change line for drive %d\n", drive); in disk_change()
747 debug_dcl(drive_params[drive].flags, "jiffies=%lu\n", jiffies); in disk_change()
748 debug_dcl(drive_params[drive].flags, "disk change line=%x\n", in disk_change()
750 debug_dcl(drive_params[drive].flags, "flags=%lx\n", in disk_change()
751 drive_state[drive].flags); in disk_change()
753 if (drive_params[drive].flags & FD_BROKEN_DCL) in disk_change()
755 &drive_state[drive].flags); in disk_change()
756 if ((fdc_inb(fdc, FD_DIR) ^ drive_params[drive].flags) & 0x80) { in disk_change()
757 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in disk_change()
760 if (drive_state[drive].maxblock) /* mark it changed */ in disk_change()
762 &drive_state[drive].flags); in disk_change()
765 if (drive_state[drive].keep_data >= 0) { in disk_change()
766 if ((drive_params[drive].flags & FTD_MSG) && in disk_change()
767 current_type[drive] != NULL) in disk_change()
769 current_type[drive] = NULL; in disk_change()
770 floppy_sizes[TOMINOR(drive)] = MAX_DISK_SIZE << 1; in disk_change()
775 drive_state[drive].last_checked = jiffies; in disk_change()
776 clear_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in disk_change()
795 unsigned char drive; in set_dor() local
807 drive = REVDRIVE(fdc, unit); in set_dor()
808 debug_dcl(drive_params[drive].flags, in set_dor()
810 disk_change(drive); in set_dor()
817 drive = REVDRIVE(fdc, unit); in set_dor()
818 drive_state[drive].select_date = jiffies; in set_dor()
824 static void twaddle(int fdc, int drive) in twaddle() argument
826 if (drive_params[drive].select_delay) in twaddle()
828 fdc_outb(fdc_state[fdc].dor & ~(0x10 << UNIT(drive)), in twaddle()
831 drive_state[drive].select_date = jiffies; in twaddle()
840 int drive; in reset_fdc_info() local
846 for (drive = 0; drive < N_DRIVE; drive++) in reset_fdc_info()
847 if (FDC(drive) == fdc && in reset_fdc_info()
848 (mode || drive_state[drive].track != NEED_1_RECAL)) in reset_fdc_info()
849 drive_state[drive].track = NEED_2_RECAL; in reset_fdc_info()
853 * selects the fdc and drive, and enables the fdc's input/dma.
854 * Both current_drive and current_fdc are changed to match the new drive.
856 static void set_fdc(int drive) in set_fdc() argument
860 if (drive < 0 || drive >= N_DRIVE) { in set_fdc()
861 pr_info("bad drive value %d\n", drive); in set_fdc()
865 fdc = FDC(drive); in set_fdc()
880 current_drive = drive; in set_fdc()
886 * Both current_drive and current_fdc are changed to match the new drive.
888 static int lock_fdc(int drive) in lock_fdc() argument
899 reschedule_timeout(drive, "lock fdc"); in lock_fdc()
900 set_fdc(drive); in lock_fdc()
932 static void floppy_off(unsigned int drive) in floppy_off() argument
935 int fdc = FDC(drive); in floppy_off()
937 if (!(fdc_state[fdc].dor & (0x10 << UNIT(drive)))) in floppy_off()
940 del_timer(motor_off_timer + drive); in floppy_off()
944 if (drive_params[drive].rps) { in floppy_off()
945 delta = jiffies - drive_state[drive].first_read_date + HZ - in floppy_off()
946 drive_params[drive].spindown_offset; in floppy_off()
947 delta = ((delta * drive_params[drive].rps) % HZ) / drive_params[drive].rps; in floppy_off()
948 motor_off_timer[drive].expires = in floppy_off()
949 jiffies + drive_params[drive].spindown - delta; in floppy_off()
951 add_timer(motor_off_timer + drive); in floppy_off()
956 * stopping at current drive. This is done before any long operation, to
962 int drive; in scandrives() local
970 drive = (saved_drive + i + 1) % N_DRIVE; in scandrives()
971 if (drive_state[drive].fd_ref == 0 || drive_params[drive].select_delay != 0) in scandrives()
973 set_fdc(drive); in scandrives()
974 if (!(set_dor(current_fdc, ~3, UNIT(drive) | (0x10 << UNIT(drive))) & in scandrives()
975 (0x10 << UNIT(drive)))) in scandrives()
978 set_dor(current_fdc, ~(0x10 << UNIT(drive)), 0); in scandrives()
1024 /* this function makes sure that the disk stays in the drive during the
1282 static void fdc_specify(int fdc, int drive) in fdc_specify() argument
1311 output_byte(fdc, UNIT(drive)); in fdc_specify()
1328 srt = 16 - DIV_ROUND_UP(drive_params[drive].srt * scale_dtr / 1000, in fdc_specify()
1336 hlt = DIV_ROUND_UP(drive_params[drive].hlt * scale_dtr / 2, in fdc_specify()
1343 hut = DIV_ROUND_UP(drive_params[drive].hut * scale_dtr / 16, in fdc_specify()
1363 /* Set the FDC's data transfer rate on behalf of the specified drive.
1376 /* TODO: some FDC/drive combinations (C&T 82C711 with TEAC 1.2MB) in fdc_dtr()
1448 DPRINT("Drive is write protected\n"); in interpret_errors()
1570 static void check_wp(int fdc, int drive) in check_wp() argument
1572 if (test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) { in check_wp()
1575 output_byte(fdc, UNIT(drive)); in check_wp()
1580 clear_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in check_wp()
1582 &drive_state[drive].flags); in check_wp()
1583 debug_dcl(drive_params[drive].flags, in check_wp()
1585 debug_dcl(drive_params[drive].flags, "wp=%x\n", in check_wp()
1589 &drive_state[drive].flags); in check_wp()
1592 &drive_state[drive].flags); in check_wp()
1609 * the drive. in seek_floppy()
1666 * reached track 0. Probably no drive. Raise an in recal_interrupt()
1785 * Must do 4 FD_SENSEIs after reset because of ``drive polling''.
1885 /* avoid dma going to a random drive after shutdown */ in floppy_shutdown()
1911 /* no read since this drive is running */ in start_motor()
1945 * drive/controller combinations */ in floppy_ready()
2072 static int next_valid_format(int drive) in next_valid_format() argument
2076 probed_format = drive_state[drive].probed_format; in next_valid_format()
2079 !drive_params[drive].autodetect[probed_format]) { in next_valid_format()
2080 drive_state[drive].probed_format = 0; in next_valid_format()
2083 if (floppy_type[drive_params[drive].autodetect[probed_format]].sect) { in next_valid_format()
2084 drive_state[drive].probed_format = probed_format; in next_valid_format()
2110 static void set_floppy(int drive) in set_floppy() argument
2112 int type = ITYPE(drive_state[drive].fd_device); in set_floppy()
2117 _floppy = current_type[drive]; in set_floppy()
2228 static int do_format(int drive, struct format_descr *tmp_format_req) in do_format() argument
2232 if (lock_fdc(drive)) in do_format()
2235 set_floppy(drive); in do_format()
2263 unsigned int drive = (unsigned long)req->q->disk->private_data; in floppy_end_request() local
2273 floppy_off(drive); in floppy_end_request()
2673 buffer_drive != current_drive || /* bad drive */ in make_raw_rw_request()
2726 pr_info("buffer drive=%d\n", buffer_drive); in make_raw_rw_request()
2775 int drive; in redo_fd_request() local
2794 drive = (long)current_req->q->disk->private_data; in redo_fd_request()
2795 set_fdc(drive); in redo_fd_request()
2798 set_floppy(drive); in redo_fd_request()
2926 * Resets the FDC connected to drive <drive>.
2927 * Both current_drive and current_fdc are changed to match the new drive.
2929 static int user_reset_fdc(int drive, int arg, bool interruptible) in user_reset_fdc() argument
2933 if (lock_fdc(drive)) in user_reset_fdc()
2967 static const char *drive_name(int type, int drive) in drive_name() argument
2974 if (drive_params[drive].native_format) in drive_name()
2975 floppy = floppy_type + drive_params[drive].native_format; in drive_name()
3139 int drive; in raw_cmd_ioctl() local
3145 for (drive = 0; drive < N_DRIVE; drive++) { in raw_cmd_ioctl()
3146 if (FDC(drive) != current_fdc) in raw_cmd_ioctl()
3148 if (drive == current_drive) { in raw_cmd_ioctl()
3149 if (drive_state[drive].fd_ref > 1) { in raw_cmd_ioctl()
3153 } else if (drive_state[drive].fd_ref) { in raw_cmd_ioctl()
3186 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3195 if (lock_fdc(drive)) in floppy_raw_cmd_ioctl()
3197 set_floppy(drive); in floppy_raw_cmd_ioctl()
3207 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3228 int drive, int type, struct block_device *bdev) in set_geometry() argument
3239 g->track <= 0 || g->track > drive_params[drive].tracks >> STRETCH(g) || in set_geometry()
3247 if (lock_fdc(drive)) { in set_geometry()
3268 if (lock_fdc(drive)) in set_geometry()
3277 user_params[drive] = *g; in set_geometry()
3278 if (buffer_drive == drive) in set_geometry()
3279 SUPBOUND(buffer_max, user_params[drive].sect); in set_geometry()
3280 current_type[drive] = &user_params[drive]; in set_geometry()
3281 floppy_sizes[drive] = user_params[drive].size; in set_geometry()
3291 if (drive_state[current_drive].maxblock > user_params[drive].sect || in set_geometry()
3293 ((user_params[drive].sect ^ oldStretch) & in set_geometry()
3349 static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) in get_floppy_geometry() argument
3354 if (lock_fdc(drive)) in get_floppy_geometry()
3359 *g = current_type[drive]; in get_floppy_geometry()
3368 int drive = (long)bdev->bd_disk->private_data; in fd_getgeo() local
3369 int type = ITYPE(drive_state[drive].fd_device); in fd_getgeo()
3373 ret = get_floppy_geometry(drive, type, &g); in fd_getgeo()
3404 int drive = (long)bdev->bd_disk->private_data; in fd_locked_ioctl() local
3405 int type = ITYPE(drive_state[drive].fd_device); in fd_locked_ioctl()
3453 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3454 /* somebody else has this drive open */ in fd_locked_ioctl()
3456 if (lock_fdc(drive)) in fd_locked_ioctl()
3461 ret = fd_eject(UNIT(drive)); in fd_locked_ioctl()
3463 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3464 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3468 if (lock_fdc(drive)) in fd_locked_ioctl()
3470 current_type[drive] = NULL; in fd_locked_ioctl()
3471 floppy_sizes[drive] = MAX_DISK_SIZE << 1; in fd_locked_ioctl()
3472 drive_state[drive].keep_data = 0; in fd_locked_ioctl()
3476 return set_geometry(cmd, &inparam.g, drive, type, bdev); in fd_locked_ioctl()
3478 ret = get_floppy_geometry(drive, type, in fd_locked_ioctl()
3487 drive_params[drive].flags |= FTD_MSG; in fd_locked_ioctl()
3490 drive_params[drive].flags &= ~FTD_MSG; in fd_locked_ioctl()
3493 if (lock_fdc(drive)) in fd_locked_ioctl()
3497 ret = drive_state[drive].flags; in fd_locked_ioctl()
3505 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3507 return do_format(drive, &inparam.f); in fd_locked_ioctl()
3510 if (lock_fdc(drive)) in fd_locked_ioctl()
3514 drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f); in fd_locked_ioctl()
3517 outparam = &drive_params[drive].max_errors; in fd_locked_ioctl()
3520 drive_params[drive].max_errors = inparam.max_errors; in fd_locked_ioctl()
3523 outparam = drive_name(type, drive); in fd_locked_ioctl()
3530 drive_params[drive] = inparam.dp; in fd_locked_ioctl()
3533 outparam = &drive_params[drive]; in fd_locked_ioctl()
3536 if (lock_fdc(drive)) in fd_locked_ioctl()
3543 outparam = &drive_state[drive]; in fd_locked_ioctl()
3546 return user_reset_fdc(drive, (int)param, true); in fd_locked_ioctl()
3548 outparam = &fdc_state[FDC(drive)]; in fd_locked_ioctl()
3551 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in fd_locked_ioctl()
3554 outparam = &write_errors[drive]; in fd_locked_ioctl()
3557 return floppy_raw_cmd_ioctl(type, drive, cmd, (void __user *)param); in fd_locked_ioctl()
3559 if (lock_fdc(drive)) in fd_locked_ioctl()
3666 int drive, type; in compat_set_geometry() local
3680 drive = (long)bdev->bd_disk->private_data; in compat_set_geometry()
3681 type = ITYPE(drive_state[drive].fd_device); in compat_set_geometry()
3683 &v, drive, type, bdev); in compat_set_geometry()
3688 static int compat_get_prm(int drive, in compat_get_prm() argument
3697 err = get_floppy_geometry(drive, ITYPE(drive_state[drive].fd_device), in compat_get_prm()
3710 static int compat_setdrvprm(int drive, in compat_setdrvprm() argument
3722 drive_params[drive].cmos = v.cmos; in compat_setdrvprm()
3723 drive_params[drive].max_dtr = v.max_dtr; in compat_setdrvprm()
3724 drive_params[drive].hlt = v.hlt; in compat_setdrvprm()
3725 drive_params[drive].hut = v.hut; in compat_setdrvprm()
3726 drive_params[drive].srt = v.srt; in compat_setdrvprm()
3727 drive_params[drive].spinup = v.spinup; in compat_setdrvprm()
3728 drive_params[drive].spindown = v.spindown; in compat_setdrvprm()
3729 drive_params[drive].spindown_offset = v.spindown_offset; in compat_setdrvprm()
3730 drive_params[drive].select_delay = v.select_delay; in compat_setdrvprm()
3731 drive_params[drive].rps = v.rps; in compat_setdrvprm()
3732 drive_params[drive].tracks = v.tracks; in compat_setdrvprm()
3733 drive_params[drive].timeout = v.timeout; in compat_setdrvprm()
3734 drive_params[drive].interleave_sect = v.interleave_sect; in compat_setdrvprm()
3735 drive_params[drive].max_errors = v.max_errors; in compat_setdrvprm()
3736 drive_params[drive].flags = v.flags; in compat_setdrvprm()
3737 drive_params[drive].read_track = v.read_track; in compat_setdrvprm()
3738 memcpy(drive_params[drive].autodetect, v.autodetect, in compat_setdrvprm()
3740 drive_params[drive].checkfreq = v.checkfreq; in compat_setdrvprm()
3741 drive_params[drive].native_format = v.native_format; in compat_setdrvprm()
3746 static int compat_getdrvprm(int drive, in compat_getdrvprm() argument
3753 v.cmos = drive_params[drive].cmos; in compat_getdrvprm()
3754 v.max_dtr = drive_params[drive].max_dtr; in compat_getdrvprm()
3755 v.hlt = drive_params[drive].hlt; in compat_getdrvprm()
3756 v.hut = drive_params[drive].hut; in compat_getdrvprm()
3757 v.srt = drive_params[drive].srt; in compat_getdrvprm()
3758 v.spinup = drive_params[drive].spinup; in compat_getdrvprm()
3759 v.spindown = drive_params[drive].spindown; in compat_getdrvprm()
3760 v.spindown_offset = drive_params[drive].spindown_offset; in compat_getdrvprm()
3761 v.select_delay = drive_params[drive].select_delay; in compat_getdrvprm()
3762 v.rps = drive_params[drive].rps; in compat_getdrvprm()
3763 v.tracks = drive_params[drive].tracks; in compat_getdrvprm()
3764 v.timeout = drive_params[drive].timeout; in compat_getdrvprm()
3765 v.interleave_sect = drive_params[drive].interleave_sect; in compat_getdrvprm()
3766 v.max_errors = drive_params[drive].max_errors; in compat_getdrvprm()
3767 v.flags = drive_params[drive].flags; in compat_getdrvprm()
3768 v.read_track = drive_params[drive].read_track; in compat_getdrvprm()
3769 memcpy(v.autodetect, drive_params[drive].autodetect, in compat_getdrvprm()
3771 v.checkfreq = drive_params[drive].checkfreq; in compat_getdrvprm()
3772 v.native_format = drive_params[drive].native_format; in compat_getdrvprm()
3780 static int compat_getdrvstat(int drive, bool poll, in compat_getdrvstat() argument
3789 if (lock_fdc(drive)) in compat_getdrvstat()
3795 v.spinup_date = drive_state[drive].spinup_date; in compat_getdrvstat()
3796 v.select_date = drive_state[drive].select_date; in compat_getdrvstat()
3797 v.first_read_date = drive_state[drive].first_read_date; in compat_getdrvstat()
3798 v.probed_format = drive_state[drive].probed_format; in compat_getdrvstat()
3799 v.track = drive_state[drive].track; in compat_getdrvstat()
3800 v.maxblock = drive_state[drive].maxblock; in compat_getdrvstat()
3801 v.maxtrack = drive_state[drive].maxtrack; in compat_getdrvstat()
3802 v.generation = drive_state[drive].generation; in compat_getdrvstat()
3803 v.keep_data = drive_state[drive].keep_data; in compat_getdrvstat()
3804 v.fd_ref = drive_state[drive].fd_ref; in compat_getdrvstat()
3805 v.fd_device = drive_state[drive].fd_device; in compat_getdrvstat()
3806 v.last_checked = drive_state[drive].last_checked; in compat_getdrvstat()
3807 v.dmabuf = (uintptr_t) drive_state[drive].dmabuf; in compat_getdrvstat()
3808 v.bufblocks = drive_state[drive].bufblocks; in compat_getdrvstat()
3819 static int compat_getfdcstat(int drive, in compat_getfdcstat() argument
3826 v = fdc_state[FDC(drive)]; in compat_getfdcstat()
3848 static int compat_werrorget(int drive, in compat_werrorget() argument
3856 v = write_errors[drive]; in compat_werrorget()
3872 int drive = (long)bdev->bd_disk->private_data; in fd_compat_ioctl() local
3900 return compat_get_prm(drive, compat_ptr(param)); in fd_compat_ioctl()
3902 return compat_setdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3904 return compat_getdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3906 return compat_getdrvstat(drive, true, compat_ptr(param)); in fd_compat_ioctl()
3908 return compat_getdrvstat(drive, false, compat_ptr(param)); in fd_compat_ioctl()
3910 return compat_getfdcstat(drive, compat_ptr(param)); in fd_compat_ioctl()
3912 return compat_werrorget(drive, compat_ptr(param)); in fd_compat_ioctl()
3921 int drive; in config_types() local
3923 /* read drive info out of physical CMOS */ in config_types()
3924 drive = 0; in config_types()
3925 if (!drive_params[drive].cmos) in config_types()
3926 drive_params[drive].cmos = FLOPPY0_TYPE; in config_types()
3927 drive = 1; in config_types()
3928 if (!drive_params[drive].cmos) in config_types()
3929 drive_params[drive].cmos = FLOPPY1_TYPE; in config_types()
3931 /* FIXME: additional physical CMOS drive detection should go here */ in config_types()
3933 for (drive = 0; drive < N_DRIVE; drive++) { in config_types()
3934 unsigned int type = drive_params[drive].cmos; in config_types()
3943 allowed_drive_mask |= 1 << drive; in config_types()
3945 allowed_drive_mask &= ~(1 << drive); in config_types()
3957 pr_info("Floppy drive(s):"); in config_types()
3962 pr_cont("%s fd%d is %s", prepend, drive, name); in config_types()
3964 drive_params[drive] = *params; in config_types()
3973 int drive = (long)disk->private_data; in floppy_release() local
3977 if (!drive_state[drive].fd_ref--) { in floppy_release()
3979 drive_state[drive].fd_ref = 0; in floppy_release()
3981 if (!drive_state[drive].fd_ref) in floppy_release()
3982 opened_disk[drive] = NULL; in floppy_release()
3990 * drive with different device numbers.
3994 int drive = (long)disk->private_data; in floppy_open() local
4002 old_dev = drive_state[drive].fd_device; in floppy_open()
4003 if (opened_disk[drive] && opened_disk[drive] != disk) in floppy_open()
4006 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) { in floppy_open()
4007 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_open()
4008 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in floppy_open()
4011 drive_state[drive].fd_ref++; in floppy_open()
4013 opened_disk[drive] = disk; in floppy_open()
4018 /* if opening an ED drive, reserve a big buffer, in floppy_open()
4020 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5)) in floppy_open()
4048 drive_state[drive].fd_device = new_dev; in floppy_open()
4049 set_capacity(disks[drive][ITYPE(new_dev)], floppy_sizes[new_dev]); in floppy_open()
4051 if (buffer_drive == drive) in floppy_open()
4055 if (fdc_state[FDC(drive)].rawcmd == 1) in floppy_open()
4056 fdc_state[FDC(drive)].rawcmd = 2; in floppy_open()
4059 drive_state[drive].last_checked = 0; in floppy_open()
4061 &drive_state[drive].flags); in floppy_open()
4064 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) in floppy_open()
4066 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) in floppy_open()
4071 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) in floppy_open()
4078 drive_state[drive].fd_ref--; in floppy_open()
4080 if (!drive_state[drive].fd_ref) in floppy_open()
4081 opened_disk[drive] = NULL; in floppy_open()
4094 int drive = (long)disk->private_data; in floppy_check_events() local
4096 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4097 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) in floppy_check_events()
4100 if (time_after(jiffies, drive_state[drive].last_checked + drive_params[drive].checkfreq)) { in floppy_check_events()
4101 if (lock_fdc(drive)) in floppy_check_events()
4107 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4108 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_check_events()
4109 test_bit(drive, &fake_change) || in floppy_check_events()
4110 drive_no_geom(drive)) in floppy_check_events()
4118 * a disk in the drive, and whether that disk is writable.
4122 int drive; member
4129 int drive = cbdata->drive; in floppy_rb0_cb() local
4134 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); in floppy_rb0_cb()
4139 static int __floppy_read_block_0(struct block_device *bdev, int drive) in __floppy_read_block_0() argument
4152 cbdata.drive = drive; in __floppy_read_block_0()
4176 * there is a disk in the drive at all... Thus we also do it for fixed
4180 int drive = (long)disk->private_data; in floppy_revalidate() local
4184 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4185 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4186 test_bit(drive, &fake_change) || in floppy_revalidate()
4187 drive_no_geom(drive)) { in floppy_revalidate()
4192 res = lock_fdc(drive); in floppy_revalidate()
4195 cf = (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4196 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)); in floppy_revalidate()
4197 if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { in floppy_revalidate()
4201 drive_state[drive].maxblock = 0; in floppy_revalidate()
4202 drive_state[drive].maxtrack = 0; in floppy_revalidate()
4203 if (buffer_drive == drive) in floppy_revalidate()
4205 clear_bit(drive, &fake_change); in floppy_revalidate()
4206 clear_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_revalidate()
4208 drive_state[drive].generation++; in floppy_revalidate()
4209 if (drive_no_geom(drive)) { in floppy_revalidate()
4211 res = __floppy_read_block_0(opened_disk[drive]->part0, in floppy_revalidate()
4212 drive); in floppy_revalidate()
4219 set_capacity(disk, floppy_sizes[drive_state[drive].fd_device]); in floppy_revalidate()
4363 DPRINT("bad drive for set_cmos\n"); in set_cmos()
4456 int drive; in floppy_cmos_show() local
4458 drive = p->id; in floppy_cmos_show()
4459 return sprintf(buf, "%X\n", drive_params[drive].cmos); in floppy_cmos_show()
4507 static bool floppy_available(int drive) in floppy_available() argument
4509 if (!(allowed_drive_mask & (1 << drive))) in floppy_available()
4511 if (fdc_state[FDC(drive)].version == FDC_NONE) in floppy_available()
4516 static int floppy_alloc_disk(unsigned int drive, unsigned int type) in floppy_alloc_disk() argument
4524 disk = blk_mq_alloc_disk(&tag_sets[drive], &lim, NULL); in floppy_alloc_disk()
4529 disk->first_minor = TOMINOR(drive) | (type << 2); in floppy_alloc_disk()
4535 sprintf(disk->disk_name, "fd%d_type%d", drive, type); in floppy_alloc_disk()
4537 sprintf(disk->disk_name, "fd%d", drive); in floppy_alloc_disk()
4539 disk->private_data = (void *)(long)drive; in floppy_alloc_disk()
4542 disks[drive][type] = disk; in floppy_alloc_disk()
4550 unsigned int drive = (MINOR(dev) & 3) | ((MINOR(dev) & 0x80) >> 5); in floppy_probe() local
4553 if (drive >= N_DRIVE || !floppy_available(drive) || in floppy_probe()
4558 if (disks[drive][type]) in floppy_probe()
4560 if (floppy_alloc_disk(drive, type)) in floppy_probe()
4562 if (add_disk(disks[drive][type])) in floppy_probe()
4569 put_disk(disks[drive][type]); in floppy_probe()
4570 disks[drive][type] = NULL; in floppy_probe()
4576 int i, unit, drive, err; in do_floppy_init() local
4592 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4593 memset(&tag_sets[drive], 0, sizeof(tag_sets[drive])); in do_floppy_init()
4594 tag_sets[drive].ops = &floppy_mq_ops; in do_floppy_init()
4595 tag_sets[drive].nr_hw_queues = 1; in do_floppy_init()
4596 tag_sets[drive].nr_maps = 1; in do_floppy_init()
4597 tag_sets[drive].queue_depth = 2; in do_floppy_init()
4598 tag_sets[drive].numa_node = NUMA_NO_NODE; in do_floppy_init()
4599 tag_sets[drive].flags = BLK_MQ_F_SHOULD_MERGE; in do_floppy_init()
4600 err = blk_mq_alloc_tag_set(&tag_sets[drive]); in do_floppy_init()
4604 err = floppy_alloc_disk(drive, 0); in do_floppy_init()
4606 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4610 timer_setup(&motor_off_timer[drive], motor_off_callback, 0); in do_floppy_init()
4662 /* initialise drive state */ in do_floppy_init()
4663 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4664 memset(&drive_state[drive], 0, sizeof(drive_state[drive])); in do_floppy_init()
4665 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in do_floppy_init()
4666 set_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in do_floppy_init()
4667 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in do_floppy_init()
4668 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in do_floppy_init()
4669 drive_state[drive].fd_device = -1; in do_floppy_init()
4723 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4724 if (!floppy_available(drive)) in do_floppy_init()
4727 floppy_device[drive].name = floppy_device_name; in do_floppy_init()
4728 floppy_device[drive].id = drive; in do_floppy_init()
4729 floppy_device[drive].dev.release = floppy_device_release; in do_floppy_init()
4730 floppy_device[drive].dev.groups = floppy_dev_groups; in do_floppy_init()
4732 err = platform_device_register(&floppy_device[drive]); in do_floppy_init()
4736 registered[drive] = true; in do_floppy_init()
4738 err = device_add_disk(&floppy_device[drive].dev, in do_floppy_init()
4739 disks[drive][0], NULL); in do_floppy_init()
4747 while (drive--) { in do_floppy_init()
4748 if (floppy_available(drive)) { in do_floppy_init()
4749 del_gendisk(disks[drive][0]); in do_floppy_init()
4750 if (registered[drive]) in do_floppy_init()
4751 platform_device_unregister(&floppy_device[drive]); in do_floppy_init()
4763 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4764 if (!disks[drive][0]) in do_floppy_init()
4766 del_timer_sync(&motor_off_timer[drive]); in do_floppy_init()
4767 put_disk(disks[drive][0]); in do_floppy_init()
4768 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4904 int drive; in floppy_release_irq_and_dma() local
4932 for (drive = 0; drive < N_FDC * 4; drive++) in floppy_release_irq_and_dma()
4933 if (timer_pending(motor_off_timer + drive)) in floppy_release_irq_and_dma()
4934 pr_info("motor off timer %d still active\n", drive); in floppy_release_irq_and_dma()
4979 int drive, i; in floppy_module_exit() local
4986 for (drive = 0; drive < N_DRIVE; drive++) { in floppy_module_exit()
4987 del_timer_sync(&motor_off_timer[drive]); in floppy_module_exit()
4989 if (floppy_available(drive)) { in floppy_module_exit()
4991 if (disks[drive][i]) in floppy_module_exit()
4992 del_gendisk(disks[drive][i]); in floppy_module_exit()
4994 if (registered[drive]) in floppy_module_exit()
4995 platform_device_unregister(&floppy_device[drive]); in floppy_module_exit()
4998 if (disks[drive][i]) in floppy_module_exit()
4999 put_disk(disks[drive][i]); in floppy_module_exit()
5001 blk_mq_free_tag_set(&tag_sets[drive]); in floppy_module_exit()