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'
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()
2225 static int do_format(int drive, struct format_descr *tmp_format_req) in do_format() argument
2229 if (lock_fdc(drive)) in do_format()
2232 set_floppy(drive); in do_format()
2260 unsigned int drive = (unsigned long)req->q->disk->private_data; in floppy_end_request() local
2270 floppy_off(drive); in floppy_end_request()
2670 buffer_drive != current_drive || /* bad drive */ in make_raw_rw_request()
2723 pr_info("buffer drive=%d\n", buffer_drive); in make_raw_rw_request()
2772 int drive; in redo_fd_request() local
2792 drive = (long)current_req->q->disk->private_data; in redo_fd_request()
2793 set_fdc(drive); in redo_fd_request()
2796 set_floppy(drive); in redo_fd_request()
2924 * Resets the FDC connected to drive <drive>.
2925 * Both current_drive and current_fdc are changed to match the new drive.
2927 static int user_reset_fdc(int drive, int arg, bool interruptible) in user_reset_fdc() argument
2931 if (lock_fdc(drive)) in user_reset_fdc()
2965 static const char *drive_name(int type, int drive) in drive_name() argument
2972 if (drive_params[drive].native_format) in drive_name()
2973 floppy = floppy_type + drive_params[drive].native_format; in drive_name()
3137 int drive; in raw_cmd_ioctl() local
3143 for (drive = 0; drive < N_DRIVE; drive++) { in raw_cmd_ioctl()
3144 if (FDC(drive) != current_fdc) in raw_cmd_ioctl()
3146 if (drive == current_drive) { in raw_cmd_ioctl()
3147 if (drive_state[drive].fd_ref > 1) { in raw_cmd_ioctl()
3151 } else if (drive_state[drive].fd_ref) { in raw_cmd_ioctl()
3184 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3193 if (lock_fdc(drive)) in floppy_raw_cmd_ioctl()
3195 set_floppy(drive); in floppy_raw_cmd_ioctl()
3205 static int floppy_raw_cmd_ioctl(int type, int drive, int cmd, in floppy_raw_cmd_ioctl() argument
3224 int drive, int type, struct block_device *bdev) in set_geometry() argument
3235 g->track <= 0 || g->track > drive_params[drive].tracks >> STRETCH(g) || in set_geometry()
3243 if (lock_fdc(drive)) { in set_geometry()
3263 if (lock_fdc(drive)) in set_geometry()
3272 user_params[drive] = *g; in set_geometry()
3273 if (buffer_drive == drive) in set_geometry()
3274 SUPBOUND(buffer_max, user_params[drive].sect); in set_geometry()
3275 current_type[drive] = &user_params[drive]; in set_geometry()
3276 floppy_sizes[drive] = user_params[drive].size; in set_geometry()
3286 if (drive_state[current_drive].maxblock > user_params[drive].sect || in set_geometry()
3288 ((user_params[drive].sect ^ oldStretch) & in set_geometry()
3344 static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) in get_floppy_geometry() argument
3349 if (lock_fdc(drive)) in get_floppy_geometry()
3354 *g = current_type[drive]; in get_floppy_geometry()
3363 int drive = (long)bdev->bd_disk->private_data; in fd_getgeo() local
3364 int type = ITYPE(drive_state[drive].fd_device); in fd_getgeo()
3368 ret = get_floppy_geometry(drive, type, &g); in fd_getgeo()
3399 int drive = (long)bdev->bd_disk->private_data; in fd_locked_ioctl() local
3400 int type = ITYPE(drive_state[drive].fd_device); in fd_locked_ioctl()
3447 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3448 /* somebody else has this drive open */ in fd_locked_ioctl()
3450 if (lock_fdc(drive)) in fd_locked_ioctl()
3455 ret = fd_eject(UNIT(drive)); in fd_locked_ioctl()
3457 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3458 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3462 if (lock_fdc(drive)) in fd_locked_ioctl()
3464 current_type[drive] = NULL; in fd_locked_ioctl()
3465 floppy_sizes[drive] = MAX_DISK_SIZE << 1; in fd_locked_ioctl()
3466 drive_state[drive].keep_data = 0; in fd_locked_ioctl()
3470 return set_geometry(cmd, &inparam.g, drive, type, bdev); in fd_locked_ioctl()
3472 ret = get_floppy_geometry(drive, type, in fd_locked_ioctl()
3481 drive_params[drive].flags |= FTD_MSG; in fd_locked_ioctl()
3484 drive_params[drive].flags &= ~FTD_MSG; in fd_locked_ioctl()
3487 if (lock_fdc(drive)) in fd_locked_ioctl()
3491 ret = drive_state[drive].flags; in fd_locked_ioctl()
3499 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3501 return do_format(drive, &inparam.f); in fd_locked_ioctl()
3504 if (lock_fdc(drive)) in fd_locked_ioctl()
3508 drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f); in fd_locked_ioctl()
3511 outparam = &drive_params[drive].max_errors; in fd_locked_ioctl()
3514 drive_params[drive].max_errors = inparam.max_errors; in fd_locked_ioctl()
3517 outparam = drive_name(type, drive); in fd_locked_ioctl()
3524 drive_params[drive] = inparam.dp; in fd_locked_ioctl()
3527 outparam = &drive_params[drive]; in fd_locked_ioctl()
3530 if (lock_fdc(drive)) in fd_locked_ioctl()
3537 outparam = &drive_state[drive]; in fd_locked_ioctl()
3540 return user_reset_fdc(drive, (int)param, true); in fd_locked_ioctl()
3542 outparam = &fdc_state[FDC(drive)]; in fd_locked_ioctl()
3545 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in fd_locked_ioctl()
3548 outparam = &write_errors[drive]; in fd_locked_ioctl()
3551 return floppy_raw_cmd_ioctl(type, drive, cmd, (void __user *)param); in fd_locked_ioctl()
3553 if (lock_fdc(drive)) in fd_locked_ioctl()
3660 int drive, type; in compat_set_geometry() local
3674 drive = (long)bdev->bd_disk->private_data; in compat_set_geometry()
3675 type = ITYPE(drive_state[drive].fd_device); in compat_set_geometry()
3677 &v, drive, type, bdev); in compat_set_geometry()
3682 static int compat_get_prm(int drive, in compat_get_prm() argument
3691 err = get_floppy_geometry(drive, ITYPE(drive_state[drive].fd_device), in compat_get_prm()
3704 static int compat_setdrvprm(int drive, in compat_setdrvprm() argument
3716 drive_params[drive].cmos = v.cmos; in compat_setdrvprm()
3717 drive_params[drive].max_dtr = v.max_dtr; in compat_setdrvprm()
3718 drive_params[drive].hlt = v.hlt; in compat_setdrvprm()
3719 drive_params[drive].hut = v.hut; in compat_setdrvprm()
3720 drive_params[drive].srt = v.srt; in compat_setdrvprm()
3721 drive_params[drive].spinup = v.spinup; in compat_setdrvprm()
3722 drive_params[drive].spindown = v.spindown; in compat_setdrvprm()
3723 drive_params[drive].spindown_offset = v.spindown_offset; in compat_setdrvprm()
3724 drive_params[drive].select_delay = v.select_delay; in compat_setdrvprm()
3725 drive_params[drive].rps = v.rps; in compat_setdrvprm()
3726 drive_params[drive].tracks = v.tracks; in compat_setdrvprm()
3727 drive_params[drive].timeout = v.timeout; in compat_setdrvprm()
3728 drive_params[drive].interleave_sect = v.interleave_sect; in compat_setdrvprm()
3729 drive_params[drive].max_errors = v.max_errors; in compat_setdrvprm()
3730 drive_params[drive].flags = v.flags; in compat_setdrvprm()
3731 drive_params[drive].read_track = v.read_track; in compat_setdrvprm()
3732 memcpy(drive_params[drive].autodetect, v.autodetect, in compat_setdrvprm()
3734 drive_params[drive].checkfreq = v.checkfreq; in compat_setdrvprm()
3735 drive_params[drive].native_format = v.native_format; in compat_setdrvprm()
3740 static int compat_getdrvprm(int drive, in compat_getdrvprm() argument
3747 v.cmos = drive_params[drive].cmos; in compat_getdrvprm()
3748 v.max_dtr = drive_params[drive].max_dtr; in compat_getdrvprm()
3749 v.hlt = drive_params[drive].hlt; in compat_getdrvprm()
3750 v.hut = drive_params[drive].hut; in compat_getdrvprm()
3751 v.srt = drive_params[drive].srt; in compat_getdrvprm()
3752 v.spinup = drive_params[drive].spinup; in compat_getdrvprm()
3753 v.spindown = drive_params[drive].spindown; in compat_getdrvprm()
3754 v.spindown_offset = drive_params[drive].spindown_offset; in compat_getdrvprm()
3755 v.select_delay = drive_params[drive].select_delay; in compat_getdrvprm()
3756 v.rps = drive_params[drive].rps; in compat_getdrvprm()
3757 v.tracks = drive_params[drive].tracks; in compat_getdrvprm()
3758 v.timeout = drive_params[drive].timeout; in compat_getdrvprm()
3759 v.interleave_sect = drive_params[drive].interleave_sect; in compat_getdrvprm()
3760 v.max_errors = drive_params[drive].max_errors; in compat_getdrvprm()
3761 v.flags = drive_params[drive].flags; in compat_getdrvprm()
3762 v.read_track = drive_params[drive].read_track; in compat_getdrvprm()
3763 memcpy(v.autodetect, drive_params[drive].autodetect, in compat_getdrvprm()
3765 v.checkfreq = drive_params[drive].checkfreq; in compat_getdrvprm()
3766 v.native_format = drive_params[drive].native_format; in compat_getdrvprm()
3774 static int compat_getdrvstat(int drive, bool poll, in compat_getdrvstat() argument
3783 if (lock_fdc(drive)) in compat_getdrvstat()
3789 v.spinup_date = drive_state[drive].spinup_date; in compat_getdrvstat()
3790 v.select_date = drive_state[drive].select_date; in compat_getdrvstat()
3791 v.first_read_date = drive_state[drive].first_read_date; in compat_getdrvstat()
3792 v.probed_format = drive_state[drive].probed_format; in compat_getdrvstat()
3793 v.track = drive_state[drive].track; in compat_getdrvstat()
3794 v.maxblock = drive_state[drive].maxblock; in compat_getdrvstat()
3795 v.maxtrack = drive_state[drive].maxtrack; in compat_getdrvstat()
3796 v.generation = drive_state[drive].generation; in compat_getdrvstat()
3797 v.keep_data = drive_state[drive].keep_data; in compat_getdrvstat()
3798 v.fd_ref = drive_state[drive].fd_ref; in compat_getdrvstat()
3799 v.fd_device = drive_state[drive].fd_device; in compat_getdrvstat()
3800 v.last_checked = drive_state[drive].last_checked; in compat_getdrvstat()
3801 v.dmabuf = (uintptr_t) drive_state[drive].dmabuf; in compat_getdrvstat()
3802 v.bufblocks = drive_state[drive].bufblocks; in compat_getdrvstat()
3813 static int compat_getfdcstat(int drive, in compat_getfdcstat() argument
3820 v = fdc_state[FDC(drive)]; in compat_getfdcstat()
3842 static int compat_werrorget(int drive, in compat_werrorget() argument
3850 v = write_errors[drive]; in compat_werrorget()
3866 int drive = (long)bdev->bd_disk->private_data; in fd_compat_ioctl() local
3894 return compat_get_prm(drive, compat_ptr(param)); in fd_compat_ioctl()
3896 return compat_setdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3898 return compat_getdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3900 return compat_getdrvstat(drive, true, compat_ptr(param)); in fd_compat_ioctl()
3902 return compat_getdrvstat(drive, false, compat_ptr(param)); in fd_compat_ioctl()
3904 return compat_getfdcstat(drive, compat_ptr(param)); in fd_compat_ioctl()
3906 return compat_werrorget(drive, compat_ptr(param)); in fd_compat_ioctl()
3915 int drive; in config_types() local
3917 /* read drive info out of physical CMOS */ in config_types()
3918 drive = 0; in config_types()
3919 if (!drive_params[drive].cmos) in config_types()
3920 drive_params[drive].cmos = FLOPPY0_TYPE; in config_types()
3921 drive = 1; in config_types()
3922 if (!drive_params[drive].cmos) in config_types()
3923 drive_params[drive].cmos = FLOPPY1_TYPE; in config_types()
3925 /* FIXME: additional physical CMOS drive detection should go here */ in config_types()
3927 for (drive = 0; drive < N_DRIVE; drive++) { in config_types()
3928 unsigned int type = drive_params[drive].cmos; in config_types()
3937 allowed_drive_mask |= 1 << drive; in config_types()
3939 allowed_drive_mask &= ~(1 << drive); in config_types()
3951 pr_info("Floppy drive(s):"); in config_types()
3956 pr_cont("%s fd%d is %s", prepend, drive, name); in config_types()
3958 drive_params[drive] = *params; in config_types()
3967 int drive = (long)disk->private_data; in floppy_release() local
3971 if (!drive_state[drive].fd_ref--) { in floppy_release()
3973 drive_state[drive].fd_ref = 0; in floppy_release()
3975 if (!drive_state[drive].fd_ref) in floppy_release()
3976 opened_bdev[drive] = NULL; in floppy_release()
3984 * drive with different device numbers.
3988 int drive = (long)bdev->bd_disk->private_data; in floppy_open() local
3996 old_dev = drive_state[drive].fd_device; in floppy_open()
3997 if (opened_bdev[drive] && opened_bdev[drive] != bdev) in floppy_open()
4000 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) { in floppy_open()
4001 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_open()
4002 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in floppy_open()
4005 drive_state[drive].fd_ref++; in floppy_open()
4007 opened_bdev[drive] = bdev; in floppy_open()
4012 /* if opening an ED drive, reserve a big buffer, in floppy_open()
4014 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5)) in floppy_open()
4042 drive_state[drive].fd_device = new_dev; in floppy_open()
4043 set_capacity(disks[drive][ITYPE(new_dev)], floppy_sizes[new_dev]); in floppy_open()
4045 if (buffer_drive == drive) in floppy_open()
4049 if (fdc_state[FDC(drive)].rawcmd == 1) in floppy_open()
4050 fdc_state[FDC(drive)].rawcmd = 2; in floppy_open()
4054 drive_state[drive].last_checked = 0; in floppy_open()
4056 &drive_state[drive].flags); in floppy_open()
4059 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) in floppy_open()
4061 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) in floppy_open()
4066 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) in floppy_open()
4073 drive_state[drive].fd_ref--; in floppy_open()
4075 if (!drive_state[drive].fd_ref) in floppy_open()
4076 opened_bdev[drive] = NULL; in floppy_open()
4089 int drive = (long)disk->private_data; in floppy_check_events() local
4091 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4092 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) in floppy_check_events()
4095 if (time_after(jiffies, drive_state[drive].last_checked + drive_params[drive].checkfreq)) { in floppy_check_events()
4096 if (lock_fdc(drive)) in floppy_check_events()
4102 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4103 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_check_events()
4104 test_bit(drive, &fake_change) || in floppy_check_events()
4105 drive_no_geom(drive)) in floppy_check_events()
4113 * a disk in the drive, and whether that disk is writable.
4117 int drive; member
4124 int drive = cbdata->drive; in floppy_rb0_cb() local
4129 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); in floppy_rb0_cb()
4134 static int __floppy_read_block_0(struct block_device *bdev, int drive) in __floppy_read_block_0() argument
4147 cbdata.drive = drive; in __floppy_read_block_0()
4171 * there is a disk in the drive at all... Thus we also do it for fixed
4175 int drive = (long)disk->private_data; in floppy_revalidate() local
4179 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4180 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4181 test_bit(drive, &fake_change) || in floppy_revalidate()
4182 drive_no_geom(drive)) { in floppy_revalidate()
4187 res = lock_fdc(drive); in floppy_revalidate()
4190 cf = (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4191 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)); in floppy_revalidate()
4192 if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { in floppy_revalidate()
4196 drive_state[drive].maxblock = 0; in floppy_revalidate()
4197 drive_state[drive].maxtrack = 0; in floppy_revalidate()
4198 if (buffer_drive == drive) in floppy_revalidate()
4200 clear_bit(drive, &fake_change); in floppy_revalidate()
4201 clear_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_revalidate()
4203 drive_state[drive].generation++; in floppy_revalidate()
4204 if (drive_no_geom(drive)) { in floppy_revalidate()
4206 res = __floppy_read_block_0(opened_bdev[drive], drive); in floppy_revalidate()
4213 set_capacity(disk, floppy_sizes[drive_state[drive].fd_device]); in floppy_revalidate()
4357 DPRINT("bad drive for set_cmos\n"); in set_cmos()
4450 int drive; in floppy_cmos_show() local
4452 drive = p->id; in floppy_cmos_show()
4453 return sprintf(buf, "%X\n", drive_params[drive].cmos); in floppy_cmos_show()
4501 static bool floppy_available(int drive) in floppy_available() argument
4503 if (!(allowed_drive_mask & (1 << drive))) in floppy_available()
4505 if (fdc_state[FDC(drive)].version == FDC_NONE) in floppy_available()
4510 static int floppy_alloc_disk(unsigned int drive, unsigned int type) in floppy_alloc_disk() argument
4514 disk = blk_mq_alloc_disk(&tag_sets[drive], NULL); in floppy_alloc_disk()
4520 disk->first_minor = TOMINOR(drive) | (type << 2); in floppy_alloc_disk()
4526 sprintf(disk->disk_name, "fd%d_type%d", drive, type); in floppy_alloc_disk()
4528 sprintf(disk->disk_name, "fd%d", drive); in floppy_alloc_disk()
4530 disk->private_data = (void *)(long)drive; in floppy_alloc_disk()
4533 disks[drive][type] = disk; in floppy_alloc_disk()
4541 unsigned int drive = (MINOR(dev) & 3) | ((MINOR(dev) & 0x80) >> 5); in floppy_probe() local
4544 if (drive >= N_DRIVE || !floppy_available(drive) || in floppy_probe()
4549 if (disks[drive][type]) in floppy_probe()
4551 if (floppy_alloc_disk(drive, type)) in floppy_probe()
4553 if (add_disk(disks[drive][type])) in floppy_probe()
4560 put_disk(disks[drive][type]); in floppy_probe()
4561 disks[drive][type] = NULL; in floppy_probe()
4567 int i, unit, drive, err; in do_floppy_init() local
4583 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4584 memset(&tag_sets[drive], 0, sizeof(tag_sets[drive])); in do_floppy_init()
4585 tag_sets[drive].ops = &floppy_mq_ops; in do_floppy_init()
4586 tag_sets[drive].nr_hw_queues = 1; in do_floppy_init()
4587 tag_sets[drive].nr_maps = 1; in do_floppy_init()
4588 tag_sets[drive].queue_depth = 2; in do_floppy_init()
4589 tag_sets[drive].numa_node = NUMA_NO_NODE; in do_floppy_init()
4590 tag_sets[drive].flags = BLK_MQ_F_SHOULD_MERGE; in do_floppy_init()
4591 err = blk_mq_alloc_tag_set(&tag_sets[drive]); in do_floppy_init()
4595 err = floppy_alloc_disk(drive, 0); in do_floppy_init()
4599 timer_setup(&motor_off_timer[drive], motor_off_callback, 0); in do_floppy_init()
4651 /* initialise drive state */ in do_floppy_init()
4652 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4653 memset(&drive_state[drive], 0, sizeof(drive_state[drive])); in do_floppy_init()
4654 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in do_floppy_init()
4655 set_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in do_floppy_init()
4656 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in do_floppy_init()
4657 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in do_floppy_init()
4658 drive_state[drive].fd_device = -1; in do_floppy_init()
4712 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4713 if (!floppy_available(drive)) in do_floppy_init()
4716 floppy_device[drive].name = floppy_device_name; in do_floppy_init()
4717 floppy_device[drive].id = drive; in do_floppy_init()
4718 floppy_device[drive].dev.release = floppy_device_release; in do_floppy_init()
4719 floppy_device[drive].dev.groups = floppy_dev_groups; in do_floppy_init()
4721 err = platform_device_register(&floppy_device[drive]); in do_floppy_init()
4725 registered[drive] = true; in do_floppy_init()
4727 err = device_add_disk(&floppy_device[drive].dev, in do_floppy_init()
4728 disks[drive][0], NULL); in do_floppy_init()
4736 while (drive--) { in do_floppy_init()
4737 if (floppy_available(drive)) { in do_floppy_init()
4738 del_gendisk(disks[drive][0]); in do_floppy_init()
4739 if (registered[drive]) in do_floppy_init()
4740 platform_device_unregister(&floppy_device[drive]); in do_floppy_init()
4752 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4753 if (!disks[drive][0]) in do_floppy_init()
4755 del_timer_sync(&motor_off_timer[drive]); in do_floppy_init()
4756 put_disk(disks[drive][0]); in do_floppy_init()
4757 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4893 int drive; in floppy_release_irq_and_dma() local
4921 for (drive = 0; drive < N_FDC * 4; drive++) in floppy_release_irq_and_dma()
4922 if (timer_pending(motor_off_timer + drive)) in floppy_release_irq_and_dma()
4923 pr_info("motor off timer %d still active\n", drive); in floppy_release_irq_and_dma()
4968 int drive, i; in floppy_module_exit() local
4975 for (drive = 0; drive < N_DRIVE; drive++) { in floppy_module_exit()
4976 del_timer_sync(&motor_off_timer[drive]); in floppy_module_exit()
4978 if (floppy_available(drive)) { in floppy_module_exit()
4980 if (disks[drive][i]) in floppy_module_exit()
4981 del_gendisk(disks[drive][i]); in floppy_module_exit()
4983 if (registered[drive]) in floppy_module_exit()
4984 platform_device_unregister(&floppy_device[drive]); in floppy_module_exit()
4987 if (disks[drive][i]) in floppy_module_exit()
4988 put_disk(disks[drive][i]); in floppy_module_exit()
4990 blk_mq_free_tag_set(&tag_sets[drive]); in floppy_module_exit()