diff -durN linux-4.6.5/drivers/block/floppy.c linux-4.6.5-patched/drivers/block/floppy.c
old
|
new
|
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /* locks the driver */ |
869 | | static int lock_fdc(int drive) |
| 869 | static int lock_fdc(int drive, bool interruptible) |
870 | 870 | { |
871 | 871 | if (WARN(atomic_read(&usage_count) == 0, |
872 | 872 | "Trying to lock fdc while usage count=0\n")) |
… |
… |
|
2173 | 2173 | { |
2174 | 2174 | int ret; |
2175 | 2175 | |
2176 | | if (lock_fdc(drive)) |
| 2176 | if (lock_fdc(drive, true)) |
2177 | 2177 | return -EINTR; |
2178 | 2178 | |
2179 | 2179 | set_floppy(drive); |
… |
… |
|
2960 | 2960 | { |
2961 | 2961 | int ret; |
2962 | 2962 | |
2963 | | if (lock_fdc(drive)) |
| 2963 | if (lock_fdc(drive, interruptible)) |
2964 | 2964 | return -EINTR; |
2965 | 2965 | |
2966 | 2966 | if (arg == FD_RESET_ALWAYS) |
… |
… |
|
3243 | 3243 | if (!capable(CAP_SYS_ADMIN)) |
3244 | 3244 | return -EPERM; |
3245 | 3245 | mutex_lock(&open_lock); |
3246 | | if (lock_fdc(drive)) { |
| 3246 | if (lock_fdc(drive, true)) { |
3247 | 3247 | mutex_unlock(&open_lock); |
3248 | 3248 | return -EINTR; |
3249 | 3249 | } |
… |
… |
|
3263 | 3263 | } else { |
3264 | 3264 | int oldStretch; |
3265 | 3265 | |
3266 | | if (lock_fdc(drive)) |
| 3266 | if (lock_fdc(drive, true)) |
3267 | 3267 | return -EINTR; |
3268 | 3268 | if (cmd != FDDEFPRM) { |
3269 | 3269 | /* notice a disk change immediately, else |
… |
… |
|
3349 | 3349 | if (type) |
3350 | 3350 | *g = &floppy_type[type]; |
3351 | 3351 | else { |
3352 | | if (lock_fdc(drive)) |
| 3352 | if (lock_fdc(drive, false)) |
3353 | 3353 | return -EINTR; |
3354 | 3354 | if (poll_drive(false, 0) == -EINTR) |
3355 | 3355 | return -EINTR; |
… |
… |
|
3433 | 3433 | if (UDRS->fd_ref != 1) |
3434 | 3434 | /* somebody else has this drive open */ |
3435 | 3435 | return -EBUSY; |
3436 | | if (lock_fdc(drive)) |
| 3436 | if (lock_fdc(drive, true)) |
3437 | 3437 | return -EINTR; |
3438 | 3438 | |
3439 | 3439 | /* do the actual eject. Fails on |
… |
… |
|
3445 | 3445 | process_fd_request(); |
3446 | 3446 | return ret; |
3447 | 3447 | case FDCLRPRM: |
3448 | | if (lock_fdc(drive)) |
| 3448 | if (lock_fdc(drive, true)) |
3449 | 3449 | return -EINTR; |
3450 | 3450 | current_type[drive] = NULL; |
3451 | 3451 | floppy_sizes[drive] = MAX_DISK_SIZE << 1; |
… |
… |
|
3467 | 3467 | UDP->flags &= ~FTD_MSG; |
3468 | 3468 | return 0; |
3469 | 3469 | case FDFMTBEG: |
3470 | | if (lock_fdc(drive)) |
| 3470 | if (lock_fdc(drive, true)) |
3471 | 3471 | return -EINTR; |
3472 | 3472 | if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) |
3473 | 3473 | return -EINTR; |
… |
… |
|
3484 | 3484 | return do_format(drive, &inparam.f); |
3485 | 3485 | case FDFMTEND: |
3486 | 3486 | case FDFLUSH: |
3487 | | if (lock_fdc(drive)) |
| 3487 | if (lock_fdc(drive, true)) |
3488 | 3488 | return -EINTR; |
3489 | 3489 | return invalidate_drive(bdev); |
3490 | 3490 | case FDSETEMSGTRESH: |
… |
… |
|
3507 | 3507 | outparam = UDP; |
3508 | 3508 | break; |
3509 | 3509 | case FDPOLLDRVSTAT: |
3510 | | if (lock_fdc(drive)) |
| 3510 | if (lock_fdc(drive, true)) |
3511 | 3511 | return -EINTR; |
3512 | 3512 | if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR) |
3513 | 3513 | return -EINTR; |
… |
… |
|
3530 | 3530 | case FDRAWCMD: |
3531 | 3531 | if (type) |
3532 | 3532 | return -EINVAL; |
3533 | | if (lock_fdc(drive)) |
| 3533 | if (lock_fdc(drive, true)) |
3534 | 3534 | return -EINTR; |
3535 | 3535 | set_floppy(drive); |
3536 | 3536 | i = raw_cmd_ioctl(cmd, (void __user *)param); |
… |
… |
|
3539 | 3539 | process_fd_request(); |
3540 | 3540 | return i; |
3541 | 3541 | case FDTWADDLE: |
3542 | | if (lock_fdc(drive)) |
| 3542 | if (lock_fdc(drive, true)) |
3543 | 3543 | return -EINTR; |
3544 | 3544 | twaddle(); |
3545 | 3545 | process_fd_request(); |
… |
… |
|
3585 | 3585 | unsigned int type = UDP->cmos; |
3586 | 3586 | struct floppy_drive_params *params; |
3587 | 3587 | const char *name = NULL; |
3588 | | char temparea[32]; |
| 3588 | static char temparea[32]; |
3589 | 3589 | |
3590 | 3590 | if (type < ARRAY_SIZE(default_drive_params)) { |
3591 | 3591 | params = &default_drive_params[type].params; |
… |
… |
|
3596 | 3596 | allowed_drive_mask &= ~(1 << drive); |
3597 | 3597 | } else { |
3598 | 3598 | params = &default_drive_params[0].params; |
3599 | | snprintf(temparea, sizeof(temparea), |
3600 | | "unknown type %d (usb?)", type); |
| 3599 | sprintf(temparea, "unknown type %d (usb?)", type); |
3601 | 3600 | name = temparea; |
3602 | 3601 | } |
3603 | 3602 | if (name) { |
… |
… |
|
3663 | 3662 | |
3664 | 3663 | opened_bdev[drive] = bdev; |
3665 | 3664 | |
3666 | | if (!(mode & (FMODE_READ|FMODE_WRITE))) { |
3667 | | res = -EINVAL; |
3668 | | goto out; |
3669 | | } |
3670 | | |
3671 | 3665 | res = -ENXIO; |
3672 | 3666 | |
3673 | 3667 | if (!floppy_track_buffer) { |
… |
… |
|
3711 | 3705 | if (UFDCS->rawcmd == 1) |
3712 | 3706 | UFDCS->rawcmd = 2; |
3713 | 3707 | |
3714 | | UDRS->last_checked = 0; |
3715 | | clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); |
3716 | | check_disk_change(bdev); |
3717 | | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) |
3718 | | goto out; |
3719 | | if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) |
3720 | | goto out; |
3721 | | |
3722 | | res = -EROFS; |
3723 | | |
3724 | | if ((mode & FMODE_WRITE) && |
3725 | | !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) |
3726 | | goto out; |
3727 | | |
| 3708 | if (!(mode & FMODE_NDELAY)) { |
| 3709 | if (mode & (FMODE_READ|FMODE_WRITE)) { |
| 3710 | UDRS->last_checked = 0; |
| 3711 | clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); |
| 3712 | check_disk_change(bdev); |
| 3713 | if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) |
| 3714 | goto out; |
| 3715 | if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) |
| 3716 | goto out; |
| 3717 | } |
| 3718 | res = -EROFS; |
| 3719 | if ((mode & FMODE_WRITE) && |
| 3720 | !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) |
| 3721 | goto out; |
| 3722 | } |
3728 | 3723 | mutex_unlock(&open_lock); |
3729 | 3724 | mutex_unlock(&floppy_mutex); |
3730 | 3725 | return 0; |
… |
… |
|
3752 | 3747 | return DISK_EVENT_MEDIA_CHANGE; |
3753 | 3748 | |
3754 | 3749 | if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) { |
3755 | | if (lock_fdc(drive)) |
3756 | | return -EINTR; |
| 3750 | lock_fdc(drive, false); |
3757 | 3751 | poll_drive(false, 0); |
3758 | 3752 | process_fd_request(); |
3759 | 3753 | } |
… |
… |
|
3852 | 3846 | "VFS: revalidate called on non-open device.\n")) |
3853 | 3847 | return -EFAULT; |
3854 | 3848 | |
3855 | | res = lock_fdc(drive); |
3856 | | if (res) |
3857 | | return res; |
| 3849 | lock_fdc(drive, false); |
3858 | 3850 | cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) || |
3859 | 3851 | test_bit(FD_VERIFY_BIT, &UDRS->flags)); |
3860 | 3852 | if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) { |