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()
3264 if (lock_fdc(drive)) in set_geometry()
3273 user_params[drive] = *g; in set_geometry()
3274 if (buffer_drive == drive) in set_geometry()
3275 SUPBOUND(buffer_max, user_params[drive].sect); in set_geometry()
3276 current_type[drive] = &user_params[drive]; in set_geometry()
3277 floppy_sizes[drive] = user_params[drive].size; in set_geometry()
3287 if (drive_state[current_drive].maxblock > user_params[drive].sect || in set_geometry()
3289 ((user_params[drive].sect ^ oldStretch) & in set_geometry()
3345 static int get_floppy_geometry(int drive, int type, struct floppy_struct **g) in get_floppy_geometry() argument
3350 if (lock_fdc(drive)) in get_floppy_geometry()
3355 *g = current_type[drive]; in get_floppy_geometry()
3364 int drive = (long)bdev->bd_disk->private_data; in fd_getgeo() local
3365 int type = ITYPE(drive_state[drive].fd_device); in fd_getgeo()
3369 ret = get_floppy_geometry(drive, type, &g); in fd_getgeo()
3400 int drive = (long)bdev->bd_disk->private_data; in fd_locked_ioctl() local
3401 int type = ITYPE(drive_state[drive].fd_device); in fd_locked_ioctl()
3449 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3450 /* somebody else has this drive open */ in fd_locked_ioctl()
3452 if (lock_fdc(drive)) in fd_locked_ioctl()
3457 ret = fd_eject(UNIT(drive)); in fd_locked_ioctl()
3459 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3460 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in fd_locked_ioctl()
3464 if (lock_fdc(drive)) in fd_locked_ioctl()
3466 current_type[drive] = NULL; in fd_locked_ioctl()
3467 floppy_sizes[drive] = MAX_DISK_SIZE << 1; in fd_locked_ioctl()
3468 drive_state[drive].keep_data = 0; in fd_locked_ioctl()
3472 return set_geometry(cmd, &inparam.g, drive, type, bdev); in fd_locked_ioctl()
3474 ret = get_floppy_geometry(drive, type, in fd_locked_ioctl()
3483 drive_params[drive].flags |= FTD_MSG; in fd_locked_ioctl()
3486 drive_params[drive].flags &= ~FTD_MSG; in fd_locked_ioctl()
3489 if (lock_fdc(drive)) in fd_locked_ioctl()
3493 ret = drive_state[drive].flags; in fd_locked_ioctl()
3501 if (drive_state[drive].fd_ref != 1) in fd_locked_ioctl()
3503 return do_format(drive, &inparam.f); in fd_locked_ioctl()
3506 if (lock_fdc(drive)) in fd_locked_ioctl()
3510 drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f); in fd_locked_ioctl()
3513 outparam = &drive_params[drive].max_errors; in fd_locked_ioctl()
3516 drive_params[drive].max_errors = inparam.max_errors; in fd_locked_ioctl()
3519 outparam = drive_name(type, drive); in fd_locked_ioctl()
3526 drive_params[drive] = inparam.dp; in fd_locked_ioctl()
3529 outparam = &drive_params[drive]; in fd_locked_ioctl()
3532 if (lock_fdc(drive)) in fd_locked_ioctl()
3539 outparam = &drive_state[drive]; in fd_locked_ioctl()
3542 return user_reset_fdc(drive, (int)param, true); in fd_locked_ioctl()
3544 outparam = &fdc_state[FDC(drive)]; in fd_locked_ioctl()
3547 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in fd_locked_ioctl()
3550 outparam = &write_errors[drive]; in fd_locked_ioctl()
3553 return floppy_raw_cmd_ioctl(type, drive, cmd, (void __user *)param); in fd_locked_ioctl()
3555 if (lock_fdc(drive)) in fd_locked_ioctl()
3662 int drive, type; in compat_set_geometry() local
3676 drive = (long)bdev->bd_disk->private_data; in compat_set_geometry()
3677 type = ITYPE(drive_state[drive].fd_device); in compat_set_geometry()
3679 &v, drive, type, bdev); in compat_set_geometry()
3684 static int compat_get_prm(int drive, in compat_get_prm() argument
3693 err = get_floppy_geometry(drive, ITYPE(drive_state[drive].fd_device), in compat_get_prm()
3706 static int compat_setdrvprm(int drive, in compat_setdrvprm() argument
3718 drive_params[drive].cmos = v.cmos; in compat_setdrvprm()
3719 drive_params[drive].max_dtr = v.max_dtr; in compat_setdrvprm()
3720 drive_params[drive].hlt = v.hlt; in compat_setdrvprm()
3721 drive_params[drive].hut = v.hut; in compat_setdrvprm()
3722 drive_params[drive].srt = v.srt; in compat_setdrvprm()
3723 drive_params[drive].spinup = v.spinup; in compat_setdrvprm()
3724 drive_params[drive].spindown = v.spindown; in compat_setdrvprm()
3725 drive_params[drive].spindown_offset = v.spindown_offset; in compat_setdrvprm()
3726 drive_params[drive].select_delay = v.select_delay; in compat_setdrvprm()
3727 drive_params[drive].rps = v.rps; in compat_setdrvprm()
3728 drive_params[drive].tracks = v.tracks; in compat_setdrvprm()
3729 drive_params[drive].timeout = v.timeout; in compat_setdrvprm()
3730 drive_params[drive].interleave_sect = v.interleave_sect; in compat_setdrvprm()
3731 drive_params[drive].max_errors = v.max_errors; in compat_setdrvprm()
3732 drive_params[drive].flags = v.flags; in compat_setdrvprm()
3733 drive_params[drive].read_track = v.read_track; in compat_setdrvprm()
3734 memcpy(drive_params[drive].autodetect, v.autodetect, in compat_setdrvprm()
3736 drive_params[drive].checkfreq = v.checkfreq; in compat_setdrvprm()
3737 drive_params[drive].native_format = v.native_format; in compat_setdrvprm()
3742 static int compat_getdrvprm(int drive, in compat_getdrvprm() argument
3749 v.cmos = drive_params[drive].cmos; in compat_getdrvprm()
3750 v.max_dtr = drive_params[drive].max_dtr; in compat_getdrvprm()
3751 v.hlt = drive_params[drive].hlt; in compat_getdrvprm()
3752 v.hut = drive_params[drive].hut; in compat_getdrvprm()
3753 v.srt = drive_params[drive].srt; in compat_getdrvprm()
3754 v.spinup = drive_params[drive].spinup; in compat_getdrvprm()
3755 v.spindown = drive_params[drive].spindown; in compat_getdrvprm()
3756 v.spindown_offset = drive_params[drive].spindown_offset; in compat_getdrvprm()
3757 v.select_delay = drive_params[drive].select_delay; in compat_getdrvprm()
3758 v.rps = drive_params[drive].rps; in compat_getdrvprm()
3759 v.tracks = drive_params[drive].tracks; in compat_getdrvprm()
3760 v.timeout = drive_params[drive].timeout; in compat_getdrvprm()
3761 v.interleave_sect = drive_params[drive].interleave_sect; in compat_getdrvprm()
3762 v.max_errors = drive_params[drive].max_errors; in compat_getdrvprm()
3763 v.flags = drive_params[drive].flags; in compat_getdrvprm()
3764 v.read_track = drive_params[drive].read_track; in compat_getdrvprm()
3765 memcpy(v.autodetect, drive_params[drive].autodetect, in compat_getdrvprm()
3767 v.checkfreq = drive_params[drive].checkfreq; in compat_getdrvprm()
3768 v.native_format = drive_params[drive].native_format; in compat_getdrvprm()
3776 static int compat_getdrvstat(int drive, bool poll, in compat_getdrvstat() argument
3785 if (lock_fdc(drive)) in compat_getdrvstat()
3791 v.spinup_date = drive_state[drive].spinup_date; in compat_getdrvstat()
3792 v.select_date = drive_state[drive].select_date; in compat_getdrvstat()
3793 v.first_read_date = drive_state[drive].first_read_date; in compat_getdrvstat()
3794 v.probed_format = drive_state[drive].probed_format; in compat_getdrvstat()
3795 v.track = drive_state[drive].track; in compat_getdrvstat()
3796 v.maxblock = drive_state[drive].maxblock; in compat_getdrvstat()
3797 v.maxtrack = drive_state[drive].maxtrack; in compat_getdrvstat()
3798 v.generation = drive_state[drive].generation; in compat_getdrvstat()
3799 v.keep_data = drive_state[drive].keep_data; in compat_getdrvstat()
3800 v.fd_ref = drive_state[drive].fd_ref; in compat_getdrvstat()
3801 v.fd_device = drive_state[drive].fd_device; in compat_getdrvstat()
3802 v.last_checked = drive_state[drive].last_checked; in compat_getdrvstat()
3803 v.dmabuf = (uintptr_t) drive_state[drive].dmabuf; in compat_getdrvstat()
3804 v.bufblocks = drive_state[drive].bufblocks; in compat_getdrvstat()
3815 static int compat_getfdcstat(int drive, in compat_getfdcstat() argument
3822 v = fdc_state[FDC(drive)]; in compat_getfdcstat()
3844 static int compat_werrorget(int drive, in compat_werrorget() argument
3852 v = write_errors[drive]; in compat_werrorget()
3868 int drive = (long)bdev->bd_disk->private_data; in fd_compat_ioctl() local
3896 return compat_get_prm(drive, compat_ptr(param)); in fd_compat_ioctl()
3898 return compat_setdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3900 return compat_getdrvprm(drive, compat_ptr(param)); in fd_compat_ioctl()
3902 return compat_getdrvstat(drive, true, compat_ptr(param)); in fd_compat_ioctl()
3904 return compat_getdrvstat(drive, false, compat_ptr(param)); in fd_compat_ioctl()
3906 return compat_getfdcstat(drive, compat_ptr(param)); in fd_compat_ioctl()
3908 return compat_werrorget(drive, compat_ptr(param)); in fd_compat_ioctl()
3917 int drive; in config_types() local
3919 /* read drive info out of physical CMOS */ in config_types()
3920 drive = 0; in config_types()
3921 if (!drive_params[drive].cmos) in config_types()
3922 drive_params[drive].cmos = FLOPPY0_TYPE; in config_types()
3923 drive = 1; in config_types()
3924 if (!drive_params[drive].cmos) in config_types()
3925 drive_params[drive].cmos = FLOPPY1_TYPE; in config_types()
3927 /* FIXME: additional physical CMOS drive detection should go here */ in config_types()
3929 for (drive = 0; drive < N_DRIVE; drive++) { in config_types()
3930 unsigned int type = drive_params[drive].cmos; in config_types()
3939 allowed_drive_mask |= 1 << drive; in config_types()
3941 allowed_drive_mask &= ~(1 << drive); in config_types()
3953 pr_info("Floppy drive(s):"); in config_types()
3958 pr_cont("%s fd%d is %s", prepend, drive, name); in config_types()
3960 drive_params[drive] = *params; in config_types()
3969 int drive = (long)disk->private_data; in floppy_release() local
3973 if (!drive_state[drive].fd_ref--) { in floppy_release()
3975 drive_state[drive].fd_ref = 0; in floppy_release()
3977 if (!drive_state[drive].fd_ref) in floppy_release()
3978 opened_disk[drive] = NULL; in floppy_release()
3986 * drive with different device numbers.
3990 int drive = (long)disk->private_data; in floppy_open() local
3998 old_dev = drive_state[drive].fd_device; in floppy_open()
3999 if (opened_disk[drive] && opened_disk[drive] != disk) in floppy_open()
4002 if (!drive_state[drive].fd_ref && (drive_params[drive].flags & FD_BROKEN_DCL)) { in floppy_open()
4003 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_open()
4004 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in floppy_open()
4007 drive_state[drive].fd_ref++; in floppy_open()
4009 opened_disk[drive] = disk; in floppy_open()
4014 /* if opening an ED drive, reserve a big buffer, in floppy_open()
4016 if ((drive_params[drive].cmos == 6) || (drive_params[drive].cmos == 5)) in floppy_open()
4044 drive_state[drive].fd_device = new_dev; in floppy_open()
4045 set_capacity(disks[drive][ITYPE(new_dev)], floppy_sizes[new_dev]); in floppy_open()
4047 if (buffer_drive == drive) in floppy_open()
4051 if (fdc_state[FDC(drive)].rawcmd == 1) in floppy_open()
4052 fdc_state[FDC(drive)].rawcmd = 2; in floppy_open()
4055 drive_state[drive].last_checked = 0; in floppy_open()
4057 &drive_state[drive].flags); in floppy_open()
4060 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) in floppy_open()
4062 if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) in floppy_open()
4067 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) in floppy_open()
4074 drive_state[drive].fd_ref--; in floppy_open()
4076 if (!drive_state[drive].fd_ref) in floppy_open()
4077 opened_disk[drive] = NULL; in floppy_open()
4090 int drive = (long)disk->private_data; in floppy_check_events() local
4092 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4093 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)) in floppy_check_events()
4096 if (time_after(jiffies, drive_state[drive].last_checked + drive_params[drive].checkfreq)) { in floppy_check_events()
4097 if (lock_fdc(drive)) in floppy_check_events()
4103 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_check_events()
4104 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_check_events()
4105 test_bit(drive, &fake_change) || in floppy_check_events()
4106 drive_no_geom(drive)) in floppy_check_events()
4114 * a disk in the drive, and whether that disk is writable.
4118 int drive; member
4125 int drive = cbdata->drive; in floppy_rb0_cb() local
4130 set_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); in floppy_rb0_cb()
4135 static int __floppy_read_block_0(struct block_device *bdev, int drive) in __floppy_read_block_0() argument
4148 cbdata.drive = drive; in __floppy_read_block_0()
4172 * there is a disk in the drive at all... Thus we also do it for fixed
4176 int drive = (long)disk->private_data; in floppy_revalidate() local
4180 if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4181 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4182 test_bit(drive, &fake_change) || in floppy_revalidate()
4183 drive_no_geom(drive)) { in floppy_revalidate()
4188 res = lock_fdc(drive); in floppy_revalidate()
4191 cf = (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags) || in floppy_revalidate()
4192 test_bit(FD_VERIFY_BIT, &drive_state[drive].flags)); in floppy_revalidate()
4193 if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { in floppy_revalidate()
4197 drive_state[drive].maxblock = 0; in floppy_revalidate()
4198 drive_state[drive].maxtrack = 0; in floppy_revalidate()
4199 if (buffer_drive == drive) in floppy_revalidate()
4201 clear_bit(drive, &fake_change); in floppy_revalidate()
4202 clear_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in floppy_revalidate()
4204 drive_state[drive].generation++; in floppy_revalidate()
4205 if (drive_no_geom(drive)) { in floppy_revalidate()
4207 res = __floppy_read_block_0(opened_disk[drive]->part0, in floppy_revalidate()
4208 drive); in floppy_revalidate()
4215 set_capacity(disk, floppy_sizes[drive_state[drive].fd_device]); in floppy_revalidate()
4359 DPRINT("bad drive for set_cmos\n"); in set_cmos()
4452 int drive; in floppy_cmos_show() local
4454 drive = p->id; in floppy_cmos_show()
4455 return sprintf(buf, "%X\n", drive_params[drive].cmos); in floppy_cmos_show()
4503 static bool floppy_available(int drive) in floppy_available() argument
4505 if (!(allowed_drive_mask & (1 << drive))) in floppy_available()
4507 if (fdc_state[FDC(drive)].version == FDC_NONE) in floppy_available()
4512 static int floppy_alloc_disk(unsigned int drive, unsigned int type) in floppy_alloc_disk() argument
4516 disk = blk_mq_alloc_disk(&tag_sets[drive], NULL); in floppy_alloc_disk()
4522 disk->first_minor = TOMINOR(drive) | (type << 2); in floppy_alloc_disk()
4528 sprintf(disk->disk_name, "fd%d_type%d", drive, type); in floppy_alloc_disk()
4530 sprintf(disk->disk_name, "fd%d", drive); in floppy_alloc_disk()
4532 disk->private_data = (void *)(long)drive; in floppy_alloc_disk()
4535 disks[drive][type] = disk; in floppy_alloc_disk()
4543 unsigned int drive = (MINOR(dev) & 3) | ((MINOR(dev) & 0x80) >> 5); in floppy_probe() local
4546 if (drive >= N_DRIVE || !floppy_available(drive) || in floppy_probe()
4551 if (disks[drive][type]) in floppy_probe()
4553 if (floppy_alloc_disk(drive, type)) in floppy_probe()
4555 if (add_disk(disks[drive][type])) in floppy_probe()
4562 put_disk(disks[drive][type]); in floppy_probe()
4563 disks[drive][type] = NULL; in floppy_probe()
4569 int i, unit, drive, err; in do_floppy_init() local
4585 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4586 memset(&tag_sets[drive], 0, sizeof(tag_sets[drive])); in do_floppy_init()
4587 tag_sets[drive].ops = &floppy_mq_ops; in do_floppy_init()
4588 tag_sets[drive].nr_hw_queues = 1; in do_floppy_init()
4589 tag_sets[drive].nr_maps = 1; in do_floppy_init()
4590 tag_sets[drive].queue_depth = 2; in do_floppy_init()
4591 tag_sets[drive].numa_node = NUMA_NO_NODE; in do_floppy_init()
4592 tag_sets[drive].flags = BLK_MQ_F_SHOULD_MERGE; in do_floppy_init()
4593 err = blk_mq_alloc_tag_set(&tag_sets[drive]); in do_floppy_init()
4597 err = floppy_alloc_disk(drive, 0); in do_floppy_init()
4599 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4603 timer_setup(&motor_off_timer[drive], motor_off_callback, 0); in do_floppy_init()
4655 /* initialise drive state */ in do_floppy_init()
4656 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4657 memset(&drive_state[drive], 0, sizeof(drive_state[drive])); in do_floppy_init()
4658 memset(&write_errors[drive], 0, sizeof(write_errors[drive])); in do_floppy_init()
4659 set_bit(FD_DISK_NEWCHANGE_BIT, &drive_state[drive].flags); in do_floppy_init()
4660 set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags); in do_floppy_init()
4661 set_bit(FD_VERIFY_BIT, &drive_state[drive].flags); in do_floppy_init()
4662 drive_state[drive].fd_device = -1; in do_floppy_init()
4716 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4717 if (!floppy_available(drive)) in do_floppy_init()
4720 floppy_device[drive].name = floppy_device_name; in do_floppy_init()
4721 floppy_device[drive].id = drive; in do_floppy_init()
4722 floppy_device[drive].dev.release = floppy_device_release; in do_floppy_init()
4723 floppy_device[drive].dev.groups = floppy_dev_groups; in do_floppy_init()
4725 err = platform_device_register(&floppy_device[drive]); in do_floppy_init()
4729 registered[drive] = true; in do_floppy_init()
4731 err = device_add_disk(&floppy_device[drive].dev, in do_floppy_init()
4732 disks[drive][0], NULL); in do_floppy_init()
4740 while (drive--) { in do_floppy_init()
4741 if (floppy_available(drive)) { in do_floppy_init()
4742 del_gendisk(disks[drive][0]); in do_floppy_init()
4743 if (registered[drive]) in do_floppy_init()
4744 platform_device_unregister(&floppy_device[drive]); in do_floppy_init()
4756 for (drive = 0; drive < N_DRIVE; drive++) { in do_floppy_init()
4757 if (!disks[drive][0]) in do_floppy_init()
4759 del_timer_sync(&motor_off_timer[drive]); in do_floppy_init()
4760 put_disk(disks[drive][0]); in do_floppy_init()
4761 blk_mq_free_tag_set(&tag_sets[drive]); in do_floppy_init()
4897 int drive; in floppy_release_irq_and_dma() local
4925 for (drive = 0; drive < N_FDC * 4; drive++) in floppy_release_irq_and_dma()
4926 if (timer_pending(motor_off_timer + drive)) in floppy_release_irq_and_dma()
4927 pr_info("motor off timer %d still active\n", drive); in floppy_release_irq_and_dma()
4972 int drive, i; in floppy_module_exit() local
4979 for (drive = 0; drive < N_DRIVE; drive++) { in floppy_module_exit()
4980 del_timer_sync(&motor_off_timer[drive]); in floppy_module_exit()
4982 if (floppy_available(drive)) { in floppy_module_exit()
4984 if (disks[drive][i]) in floppy_module_exit()
4985 del_gendisk(disks[drive][i]); in floppy_module_exit()
4987 if (registered[drive]) in floppy_module_exit()
4988 platform_device_unregister(&floppy_device[drive]); in floppy_module_exit()
4991 if (disks[drive][i]) in floppy_module_exit()
4992 put_disk(disks[drive][i]); in floppy_module_exit()
4994 blk_mq_free_tag_set(&tag_sets[drive]); in floppy_module_exit()