diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 12:05:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-30 12:05:47 -0400 |
commit | a70f35af4e49f87ba4b6c4b30220fbb66cd74af6 (patch) | |
tree | f81d1c68d332f7ed32048085fa2972c057f62419 /drivers/block/floppy.c | |
parent | 0d167518e045cc8bb63f0a8a0a85ad4fa4e0044f (diff) | |
parent | 4fd1ffaa122cf66bfb710ced43679413df4f3605 (diff) |
Merge branch 'for-3.5/drivers' of git://git.kernel.dk/linux-block
Pull block driver updates from Jens Axboe:
"Here are the driver related changes for 3.5. It contains:
- The floppy changes from Jiri. Jiri is now also marked as the
maintainer of floppy.c, I shall be publically branding his forehead
with red hot iron at the next opportune moment.
- A batch of drbd updates and fixes from the linbit crew, as well as
fixes from others.
- Two small fixes for xen-blkfront courtesy of Jan."
* 'for-3.5/drivers' of git://git.kernel.dk/linux-block: (70 commits)
floppy: take over maintainership
floppy: remove floppy-specific O_EXCL handling
floppy: convert to delayed work and single-thread wq
xen-blkfront: module exit handling adjustments
xen-blkfront: properly name all devices
drbd: grammar fix in log message
drbd: check MODULE for THIS_MODULE
drbd: Restore the request restart logic
drbd: introduce a bio_set to allocate housekeeping bios from
drbd: remove unused define
drbd: bm_page_async_io: properly initialize page->private
drbd: use the newly introduced page pool for bitmap IO
drbd: add page pool to be used for meta data IO
drbd: allow bitmap to change during writeout from resync_finished
drbd: fix race between drbdadm invalidate/verify and finishing resync
drbd: fix resend/resubmit of frozen IO
drbd: Ensure that data_size is not 0 before using data_size-1 as index
drbd: Delay/reject other state changes while establishing a connection
drbd: move put_ldev from __req_mod() to the endio callback
drbd: fix WRITE_ACKED_BY_PEER_AND_SIS to not set RQ_NET_DONE
...
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 161 |
1 files changed, 77 insertions, 84 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index b0b00d70c166..cce7df367b79 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -551,7 +551,7 @@ static void floppy_ready(void); | |||
551 | static void floppy_start(void); | 551 | static void floppy_start(void); |
552 | static void process_fd_request(void); | 552 | static void process_fd_request(void); |
553 | static void recalibrate_floppy(void); | 553 | static void recalibrate_floppy(void); |
554 | static void floppy_shutdown(unsigned long); | 554 | static void floppy_shutdown(struct work_struct *); |
555 | 555 | ||
556 | static int floppy_request_regions(int); | 556 | static int floppy_request_regions(int); |
557 | static void floppy_release_regions(int); | 557 | static void floppy_release_regions(int); |
@@ -588,6 +588,8 @@ static int buffer_max = -1; | |||
588 | static struct floppy_fdc_state fdc_state[N_FDC]; | 588 | static struct floppy_fdc_state fdc_state[N_FDC]; |
589 | static int fdc; /* current fdc */ | 589 | static int fdc; /* current fdc */ |
590 | 590 | ||
591 | static struct workqueue_struct *floppy_wq; | ||
592 | |||
591 | static struct floppy_struct *_floppy = floppy_type; | 593 | static struct floppy_struct *_floppy = floppy_type; |
592 | static unsigned char current_drive; | 594 | static unsigned char current_drive; |
593 | static long current_count_sectors; | 595 | static long current_count_sectors; |
@@ -629,16 +631,15 @@ static inline void set_debugt(void) { } | |||
629 | static inline void debugt(const char *func, const char *msg) { } | 631 | static inline void debugt(const char *func, const char *msg) { } |
630 | #endif /* DEBUGT */ | 632 | #endif /* DEBUGT */ |
631 | 633 | ||
632 | typedef void (*timeout_fn)(unsigned long); | ||
633 | static DEFINE_TIMER(fd_timeout, floppy_shutdown, 0, 0); | ||
634 | 634 | ||
635 | static DECLARE_DELAYED_WORK(fd_timeout, floppy_shutdown); | ||
635 | static const char *timeout_message; | 636 | static const char *timeout_message; |
636 | 637 | ||
637 | static void is_alive(const char *func, const char *message) | 638 | static void is_alive(const char *func, const char *message) |
638 | { | 639 | { |
639 | /* this routine checks whether the floppy driver is "alive" */ | 640 | /* this routine checks whether the floppy driver is "alive" */ |
640 | if (test_bit(0, &fdc_busy) && command_status < 2 && | 641 | if (test_bit(0, &fdc_busy) && command_status < 2 && |
641 | !timer_pending(&fd_timeout)) { | 642 | !delayed_work_pending(&fd_timeout)) { |
642 | DPRINT("%s: timeout handler died. %s\n", func, message); | 643 | DPRINT("%s: timeout handler died. %s\n", func, message); |
643 | } | 644 | } |
644 | } | 645 | } |
@@ -666,15 +667,18 @@ static int output_log_pos; | |||
666 | 667 | ||
667 | static void __reschedule_timeout(int drive, const char *message) | 668 | static void __reschedule_timeout(int drive, const char *message) |
668 | { | 669 | { |
670 | unsigned long delay; | ||
671 | |||
669 | if (drive == current_reqD) | 672 | if (drive == current_reqD) |
670 | drive = current_drive; | 673 | drive = current_drive; |
671 | del_timer(&fd_timeout); | 674 | |
672 | if (drive < 0 || drive >= N_DRIVE) { | 675 | if (drive < 0 || drive >= N_DRIVE) { |
673 | fd_timeout.expires = jiffies + 20UL * HZ; | 676 | delay = 20UL * HZ; |
674 | drive = 0; | 677 | drive = 0; |
675 | } else | 678 | } else |
676 | fd_timeout.expires = jiffies + UDP->timeout; | 679 | delay = UDP->timeout; |
677 | add_timer(&fd_timeout); | 680 | |
681 | queue_delayed_work(floppy_wq, &fd_timeout, delay); | ||
678 | if (UDP->flags & FD_DEBUG) | 682 | if (UDP->flags & FD_DEBUG) |
679 | DPRINT("reschedule timeout %s\n", message); | 683 | DPRINT("reschedule timeout %s\n", message); |
680 | timeout_message = message; | 684 | timeout_message = message; |
@@ -872,7 +876,7 @@ static int lock_fdc(int drive, bool interruptible) | |||
872 | 876 | ||
873 | command_status = FD_COMMAND_NONE; | 877 | command_status = FD_COMMAND_NONE; |
874 | 878 | ||
875 | __reschedule_timeout(drive, "lock fdc"); | 879 | reschedule_timeout(drive, "lock fdc"); |
876 | set_fdc(drive); | 880 | set_fdc(drive); |
877 | return 0; | 881 | return 0; |
878 | } | 882 | } |
@@ -880,23 +884,15 @@ static int lock_fdc(int drive, bool interruptible) | |||
880 | /* unlocks the driver */ | 884 | /* unlocks the driver */ |
881 | static void unlock_fdc(void) | 885 | static void unlock_fdc(void) |
882 | { | 886 | { |
883 | unsigned long flags; | ||
884 | |||
885 | raw_cmd = NULL; | ||
886 | if (!test_bit(0, &fdc_busy)) | 887 | if (!test_bit(0, &fdc_busy)) |
887 | DPRINT("FDC access conflict!\n"); | 888 | DPRINT("FDC access conflict!\n"); |
888 | 889 | ||
889 | if (do_floppy) | 890 | raw_cmd = NULL; |
890 | DPRINT("device interrupt still active at FDC release: %pf!\n", | ||
891 | do_floppy); | ||
892 | command_status = FD_COMMAND_NONE; | 891 | command_status = FD_COMMAND_NONE; |
893 | spin_lock_irqsave(&floppy_lock, flags); | 892 | __cancel_delayed_work(&fd_timeout); |
894 | del_timer(&fd_timeout); | 893 | do_floppy = NULL; |
895 | cont = NULL; | 894 | cont = NULL; |
896 | clear_bit(0, &fdc_busy); | 895 | clear_bit(0, &fdc_busy); |
897 | if (current_req || set_next_request()) | ||
898 | do_fd_request(current_req->q); | ||
899 | spin_unlock_irqrestore(&floppy_lock, flags); | ||
900 | wake_up(&fdc_wait); | 896 | wake_up(&fdc_wait); |
901 | } | 897 | } |
902 | 898 | ||
@@ -968,26 +964,24 @@ static DECLARE_WORK(floppy_work, NULL); | |||
968 | 964 | ||
969 | static void schedule_bh(void (*handler)(void)) | 965 | static void schedule_bh(void (*handler)(void)) |
970 | { | 966 | { |
967 | WARN_ON(work_pending(&floppy_work)); | ||
968 | |||
971 | PREPARE_WORK(&floppy_work, (work_func_t)handler); | 969 | PREPARE_WORK(&floppy_work, (work_func_t)handler); |
972 | schedule_work(&floppy_work); | 970 | queue_work(floppy_wq, &floppy_work); |
973 | } | 971 | } |
974 | 972 | ||
975 | static DEFINE_TIMER(fd_timer, NULL, 0, 0); | 973 | static DECLARE_DELAYED_WORK(fd_timer, NULL); |
976 | 974 | ||
977 | static void cancel_activity(void) | 975 | static void cancel_activity(void) |
978 | { | 976 | { |
979 | unsigned long flags; | ||
980 | |||
981 | spin_lock_irqsave(&floppy_lock, flags); | ||
982 | do_floppy = NULL; | 977 | do_floppy = NULL; |
983 | PREPARE_WORK(&floppy_work, (work_func_t)empty); | 978 | cancel_delayed_work_sync(&fd_timer); |
984 | del_timer(&fd_timer); | 979 | cancel_work_sync(&floppy_work); |
985 | spin_unlock_irqrestore(&floppy_lock, flags); | ||
986 | } | 980 | } |
987 | 981 | ||
988 | /* this function makes sure that the disk stays in the drive during the | 982 | /* this function makes sure that the disk stays in the drive during the |
989 | * transfer */ | 983 | * transfer */ |
990 | static void fd_watchdog(void) | 984 | static void fd_watchdog(struct work_struct *arg) |
991 | { | 985 | { |
992 | debug_dcl(DP->flags, "calling disk change from watchdog\n"); | 986 | debug_dcl(DP->flags, "calling disk change from watchdog\n"); |
993 | 987 | ||
@@ -997,21 +991,20 @@ static void fd_watchdog(void) | |||
997 | cont->done(0); | 991 | cont->done(0); |
998 | reset_fdc(); | 992 | reset_fdc(); |
999 | } else { | 993 | } else { |
1000 | del_timer(&fd_timer); | 994 | cancel_delayed_work(&fd_timer); |
1001 | fd_timer.function = (timeout_fn)fd_watchdog; | 995 | PREPARE_DELAYED_WORK(&fd_timer, fd_watchdog); |
1002 | fd_timer.expires = jiffies + HZ / 10; | 996 | queue_delayed_work(floppy_wq, &fd_timer, HZ / 10); |
1003 | add_timer(&fd_timer); | ||
1004 | } | 997 | } |
1005 | } | 998 | } |
1006 | 999 | ||
1007 | static void main_command_interrupt(void) | 1000 | static void main_command_interrupt(void) |
1008 | { | 1001 | { |
1009 | del_timer(&fd_timer); | 1002 | cancel_delayed_work(&fd_timer); |
1010 | cont->interrupt(); | 1003 | cont->interrupt(); |
1011 | } | 1004 | } |
1012 | 1005 | ||
1013 | /* waits for a delay (spinup or select) to pass */ | 1006 | /* waits for a delay (spinup or select) to pass */ |
1014 | static int fd_wait_for_completion(unsigned long delay, timeout_fn function) | 1007 | static int fd_wait_for_completion(unsigned long expires, work_func_t function) |
1015 | { | 1008 | { |
1016 | if (FDCS->reset) { | 1009 | if (FDCS->reset) { |
1017 | reset_fdc(); /* do the reset during sleep to win time | 1010 | reset_fdc(); /* do the reset during sleep to win time |
@@ -1020,11 +1013,10 @@ static int fd_wait_for_completion(unsigned long delay, timeout_fn function) | |||
1020 | return 1; | 1013 | return 1; |
1021 | } | 1014 | } |
1022 | 1015 | ||
1023 | if (time_before(jiffies, delay)) { | 1016 | if (time_before(jiffies, expires)) { |
1024 | del_timer(&fd_timer); | 1017 | cancel_delayed_work(&fd_timer); |
1025 | fd_timer.function = function; | 1018 | PREPARE_DELAYED_WORK(&fd_timer, function); |
1026 | fd_timer.expires = delay; | 1019 | queue_delayed_work(floppy_wq, &fd_timer, expires - jiffies); |
1027 | add_timer(&fd_timer); | ||
1028 | return 1; | 1020 | return 1; |
1029 | } | 1021 | } |
1030 | return 0; | 1022 | return 0; |
@@ -1342,7 +1334,7 @@ static int fdc_dtr(void) | |||
1342 | */ | 1334 | */ |
1343 | FDCS->dtr = raw_cmd->rate & 3; | 1335 | FDCS->dtr = raw_cmd->rate & 3; |
1344 | return fd_wait_for_completion(jiffies + 2UL * HZ / 100, | 1336 | return fd_wait_for_completion(jiffies + 2UL * HZ / 100, |
1345 | (timeout_fn)floppy_ready); | 1337 | (work_func_t)floppy_ready); |
1346 | } /* fdc_dtr */ | 1338 | } /* fdc_dtr */ |
1347 | 1339 | ||
1348 | static void tell_sector(void) | 1340 | static void tell_sector(void) |
@@ -1447,7 +1439,7 @@ static void setup_rw_floppy(void) | |||
1447 | int flags; | 1439 | int flags; |
1448 | int dflags; | 1440 | int dflags; |
1449 | unsigned long ready_date; | 1441 | unsigned long ready_date; |
1450 | timeout_fn function; | 1442 | work_func_t function; |
1451 | 1443 | ||
1452 | flags = raw_cmd->flags; | 1444 | flags = raw_cmd->flags; |
1453 | if (flags & (FD_RAW_READ | FD_RAW_WRITE)) | 1445 | if (flags & (FD_RAW_READ | FD_RAW_WRITE)) |
@@ -1461,9 +1453,9 @@ static void setup_rw_floppy(void) | |||
1461 | */ | 1453 | */ |
1462 | if (time_after(ready_date, jiffies + DP->select_delay)) { | 1454 | if (time_after(ready_date, jiffies + DP->select_delay)) { |
1463 | ready_date -= DP->select_delay; | 1455 | ready_date -= DP->select_delay; |
1464 | function = (timeout_fn)floppy_start; | 1456 | function = (work_func_t)floppy_start; |
1465 | } else | 1457 | } else |
1466 | function = (timeout_fn)setup_rw_floppy; | 1458 | function = (work_func_t)setup_rw_floppy; |
1467 | 1459 | ||
1468 | /* wait until the floppy is spinning fast enough */ | 1460 | /* wait until the floppy is spinning fast enough */ |
1469 | if (fd_wait_for_completion(ready_date, function)) | 1461 | if (fd_wait_for_completion(ready_date, function)) |
@@ -1493,7 +1485,7 @@ static void setup_rw_floppy(void) | |||
1493 | inr = result(); | 1485 | inr = result(); |
1494 | cont->interrupt(); | 1486 | cont->interrupt(); |
1495 | } else if (flags & FD_RAW_NEED_DISK) | 1487 | } else if (flags & FD_RAW_NEED_DISK) |
1496 | fd_watchdog(); | 1488 | fd_watchdog(NULL); |
1497 | } | 1489 | } |
1498 | 1490 | ||
1499 | static int blind_seek; | 1491 | static int blind_seek; |
@@ -1802,20 +1794,22 @@ static void show_floppy(void) | |||
1802 | pr_info("do_floppy=%pf\n", do_floppy); | 1794 | pr_info("do_floppy=%pf\n", do_floppy); |
1803 | if (work_pending(&floppy_work)) | 1795 | if (work_pending(&floppy_work)) |
1804 | pr_info("floppy_work.func=%pf\n", floppy_work.func); | 1796 | pr_info("floppy_work.func=%pf\n", floppy_work.func); |
1805 | if (timer_pending(&fd_timer)) | 1797 | if (delayed_work_pending(&fd_timer)) |
1806 | pr_info("fd_timer.function=%pf\n", fd_timer.function); | 1798 | pr_info("delayed work.function=%p expires=%ld\n", |
1807 | if (timer_pending(&fd_timeout)) { | 1799 | fd_timer.work.func, |
1808 | pr_info("timer_function=%pf\n", fd_timeout.function); | 1800 | fd_timer.timer.expires - jiffies); |
1809 | pr_info("expires=%lu\n", fd_timeout.expires - jiffies); | 1801 | if (delayed_work_pending(&fd_timeout)) |
1810 | pr_info("now=%lu\n", jiffies); | 1802 | pr_info("timer_function=%p expires=%ld\n", |
1811 | } | 1803 | fd_timeout.work.func, |
1804 | fd_timeout.timer.expires - jiffies); | ||
1805 | |||
1812 | pr_info("cont=%p\n", cont); | 1806 | pr_info("cont=%p\n", cont); |
1813 | pr_info("current_req=%p\n", current_req); | 1807 | pr_info("current_req=%p\n", current_req); |
1814 | pr_info("command_status=%d\n", command_status); | 1808 | pr_info("command_status=%d\n", command_status); |
1815 | pr_info("\n"); | 1809 | pr_info("\n"); |
1816 | } | 1810 | } |
1817 | 1811 | ||
1818 | static void floppy_shutdown(unsigned long data) | 1812 | static void floppy_shutdown(struct work_struct *arg) |
1819 | { | 1813 | { |
1820 | unsigned long flags; | 1814 | unsigned long flags; |
1821 | 1815 | ||
@@ -1868,7 +1862,7 @@ static int start_motor(void (*function)(void)) | |||
1868 | 1862 | ||
1869 | /* wait_for_completion also schedules reset if needed. */ | 1863 | /* wait_for_completion also schedules reset if needed. */ |
1870 | return fd_wait_for_completion(DRS->select_date + DP->select_delay, | 1864 | return fd_wait_for_completion(DRS->select_date + DP->select_delay, |
1871 | (timeout_fn)function); | 1865 | (work_func_t)function); |
1872 | } | 1866 | } |
1873 | 1867 | ||
1874 | static void floppy_ready(void) | 1868 | static void floppy_ready(void) |
@@ -2821,7 +2815,6 @@ do_request: | |||
2821 | spin_lock_irq(&floppy_lock); | 2815 | spin_lock_irq(&floppy_lock); |
2822 | pending = set_next_request(); | 2816 | pending = set_next_request(); |
2823 | spin_unlock_irq(&floppy_lock); | 2817 | spin_unlock_irq(&floppy_lock); |
2824 | |||
2825 | if (!pending) { | 2818 | if (!pending) { |
2826 | do_floppy = NULL; | 2819 | do_floppy = NULL; |
2827 | unlock_fdc(); | 2820 | unlock_fdc(); |
@@ -2898,13 +2891,15 @@ static void do_fd_request(struct request_queue *q) | |||
2898 | current_req->cmd_flags)) | 2891 | current_req->cmd_flags)) |
2899 | return; | 2892 | return; |
2900 | 2893 | ||
2901 | if (test_bit(0, &fdc_busy)) { | 2894 | if (test_and_set_bit(0, &fdc_busy)) { |
2902 | /* fdc busy, this new request will be treated when the | 2895 | /* fdc busy, this new request will be treated when the |
2903 | current one is done */ | 2896 | current one is done */ |
2904 | is_alive(__func__, "old request running"); | 2897 | is_alive(__func__, "old request running"); |
2905 | return; | 2898 | return; |
2906 | } | 2899 | } |
2907 | lock_fdc(MAXTIMEOUT, false); | 2900 | command_status = FD_COMMAND_NONE; |
2901 | __reschedule_timeout(MAXTIMEOUT, "fd_request"); | ||
2902 | set_fdc(0); | ||
2908 | process_fd_request(); | 2903 | process_fd_request(); |
2909 | is_alive(__func__, ""); | 2904 | is_alive(__func__, ""); |
2910 | } | 2905 | } |
@@ -3612,9 +3607,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode) | |||
3612 | 3607 | ||
3613 | mutex_lock(&floppy_mutex); | 3608 | mutex_lock(&floppy_mutex); |
3614 | mutex_lock(&open_lock); | 3609 | mutex_lock(&open_lock); |
3615 | if (UDRS->fd_ref < 0) | 3610 | if (!UDRS->fd_ref--) { |
3616 | UDRS->fd_ref = 0; | ||
3617 | else if (!UDRS->fd_ref--) { | ||
3618 | DPRINT("floppy_release with fd_ref == 0"); | 3611 | DPRINT("floppy_release with fd_ref == 0"); |
3619 | UDRS->fd_ref = 0; | 3612 | UDRS->fd_ref = 0; |
3620 | } | 3613 | } |
@@ -3650,13 +3643,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3650 | set_bit(FD_VERIFY_BIT, &UDRS->flags); | 3643 | set_bit(FD_VERIFY_BIT, &UDRS->flags); |
3651 | } | 3644 | } |
3652 | 3645 | ||
3653 | if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (mode & FMODE_EXCL))) | 3646 | UDRS->fd_ref++; |
3654 | goto out2; | ||
3655 | |||
3656 | if (mode & FMODE_EXCL) | ||
3657 | UDRS->fd_ref = -1; | ||
3658 | else | ||
3659 | UDRS->fd_ref++; | ||
3660 | 3647 | ||
3661 | opened_bdev[drive] = bdev; | 3648 | opened_bdev[drive] = bdev; |
3662 | 3649 | ||
@@ -3719,10 +3706,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) | |||
3719 | mutex_unlock(&floppy_mutex); | 3706 | mutex_unlock(&floppy_mutex); |
3720 | return 0; | 3707 | return 0; |
3721 | out: | 3708 | out: |
3722 | if (UDRS->fd_ref < 0) | 3709 | UDRS->fd_ref--; |
3723 | UDRS->fd_ref = 0; | 3710 | |
3724 | else | ||
3725 | UDRS->fd_ref--; | ||
3726 | if (!UDRS->fd_ref) | 3711 | if (!UDRS->fd_ref) |
3727 | opened_bdev[drive] = NULL; | 3712 | opened_bdev[drive] = NULL; |
3728 | out2: | 3713 | out2: |
@@ -4159,10 +4144,16 @@ static int __init floppy_init(void) | |||
4159 | goto out_put_disk; | 4144 | goto out_put_disk; |
4160 | } | 4145 | } |
4161 | 4146 | ||
4147 | floppy_wq = alloc_ordered_workqueue("floppy", 0); | ||
4148 | if (!floppy_wq) { | ||
4149 | err = -ENOMEM; | ||
4150 | goto out_put_disk; | ||
4151 | } | ||
4152 | |||
4162 | disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock); | 4153 | disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock); |
4163 | if (!disks[dr]->queue) { | 4154 | if (!disks[dr]->queue) { |
4164 | err = -ENOMEM; | 4155 | err = -ENOMEM; |
4165 | goto out_put_disk; | 4156 | goto out_destroy_workq; |
4166 | } | 4157 | } |
4167 | 4158 | ||
4168 | blk_queue_max_hw_sectors(disks[dr]->queue, 64); | 4159 | blk_queue_max_hw_sectors(disks[dr]->queue, 64); |
@@ -4213,7 +4204,7 @@ static int __init floppy_init(void) | |||
4213 | use_virtual_dma = can_use_virtual_dma & 1; | 4204 | use_virtual_dma = can_use_virtual_dma & 1; |
4214 | fdc_state[0].address = FDC1; | 4205 | fdc_state[0].address = FDC1; |
4215 | if (fdc_state[0].address == -1) { | 4206 | if (fdc_state[0].address == -1) { |
4216 | del_timer_sync(&fd_timeout); | 4207 | cancel_delayed_work(&fd_timeout); |
4217 | err = -ENODEV; | 4208 | err = -ENODEV; |
4218 | goto out_unreg_region; | 4209 | goto out_unreg_region; |
4219 | } | 4210 | } |
@@ -4224,7 +4215,7 @@ static int __init floppy_init(void) | |||
4224 | fdc = 0; /* reset fdc in case of unexpected interrupt */ | 4215 | fdc = 0; /* reset fdc in case of unexpected interrupt */ |
4225 | err = floppy_grab_irq_and_dma(); | 4216 | err = floppy_grab_irq_and_dma(); |
4226 | if (err) { | 4217 | if (err) { |
4227 | del_timer_sync(&fd_timeout); | 4218 | cancel_delayed_work(&fd_timeout); |
4228 | err = -EBUSY; | 4219 | err = -EBUSY; |
4229 | goto out_unreg_region; | 4220 | goto out_unreg_region; |
4230 | } | 4221 | } |
@@ -4281,13 +4272,13 @@ static int __init floppy_init(void) | |||
4281 | user_reset_fdc(-1, FD_RESET_ALWAYS, false); | 4272 | user_reset_fdc(-1, FD_RESET_ALWAYS, false); |
4282 | } | 4273 | } |
4283 | fdc = 0; | 4274 | fdc = 0; |
4284 | del_timer_sync(&fd_timeout); | 4275 | cancel_delayed_work(&fd_timeout); |
4285 | current_drive = 0; | 4276 | current_drive = 0; |
4286 | initialized = true; | 4277 | initialized = true; |
4287 | if (have_no_fdc) { | 4278 | if (have_no_fdc) { |
4288 | DPRINT("no floppy controllers found\n"); | 4279 | DPRINT("no floppy controllers found\n"); |
4289 | err = have_no_fdc; | 4280 | err = have_no_fdc; |
4290 | goto out_flush_work; | 4281 | goto out_release_dma; |
4291 | } | 4282 | } |
4292 | 4283 | ||
4293 | for (drive = 0; drive < N_DRIVE; drive++) { | 4284 | for (drive = 0; drive < N_DRIVE; drive++) { |
@@ -4302,7 +4293,7 @@ static int __init floppy_init(void) | |||
4302 | 4293 | ||
4303 | err = platform_device_register(&floppy_device[drive]); | 4294 | err = platform_device_register(&floppy_device[drive]); |
4304 | if (err) | 4295 | if (err) |
4305 | goto out_flush_work; | 4296 | goto out_release_dma; |
4306 | 4297 | ||
4307 | err = device_create_file(&floppy_device[drive].dev, | 4298 | err = device_create_file(&floppy_device[drive].dev, |
4308 | &dev_attr_cmos); | 4299 | &dev_attr_cmos); |
@@ -4320,13 +4311,14 @@ static int __init floppy_init(void) | |||
4320 | 4311 | ||
4321 | out_unreg_platform_dev: | 4312 | out_unreg_platform_dev: |
4322 | platform_device_unregister(&floppy_device[drive]); | 4313 | platform_device_unregister(&floppy_device[drive]); |
4323 | out_flush_work: | 4314 | out_release_dma: |
4324 | flush_work_sync(&floppy_work); | ||
4325 | if (atomic_read(&usage_count)) | 4315 | if (atomic_read(&usage_count)) |
4326 | floppy_release_irq_and_dma(); | 4316 | floppy_release_irq_and_dma(); |
4327 | out_unreg_region: | 4317 | out_unreg_region: |
4328 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); | 4318 | blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); |
4329 | platform_driver_unregister(&floppy_driver); | 4319 | platform_driver_unregister(&floppy_driver); |
4320 | out_destroy_workq: | ||
4321 | destroy_workqueue(floppy_wq); | ||
4330 | out_unreg_blkdev: | 4322 | out_unreg_blkdev: |
4331 | unregister_blkdev(FLOPPY_MAJOR, "fd"); | 4323 | unregister_blkdev(FLOPPY_MAJOR, "fd"); |
4332 | out_put_disk: | 4324 | out_put_disk: |
@@ -4397,7 +4389,7 @@ static int floppy_grab_irq_and_dma(void) | |||
4397 | * We might have scheduled a free_irq(), wait it to | 4389 | * We might have scheduled a free_irq(), wait it to |
4398 | * drain first: | 4390 | * drain first: |
4399 | */ | 4391 | */ |
4400 | flush_work_sync(&floppy_work); | 4392 | flush_workqueue(floppy_wq); |
4401 | 4393 | ||
4402 | if (fd_request_irq()) { | 4394 | if (fd_request_irq()) { |
4403 | DPRINT("Unable to grab IRQ%d for the floppy driver\n", | 4395 | DPRINT("Unable to grab IRQ%d for the floppy driver\n", |
@@ -4488,9 +4480,9 @@ static void floppy_release_irq_and_dma(void) | |||
4488 | pr_info("motor off timer %d still active\n", drive); | 4480 | pr_info("motor off timer %d still active\n", drive); |
4489 | #endif | 4481 | #endif |
4490 | 4482 | ||
4491 | if (timer_pending(&fd_timeout)) | 4483 | if (delayed_work_pending(&fd_timeout)) |
4492 | pr_info("floppy timer still active:%s\n", timeout_message); | 4484 | pr_info("floppy timer still active:%s\n", timeout_message); |
4493 | if (timer_pending(&fd_timer)) | 4485 | if (delayed_work_pending(&fd_timer)) |
4494 | pr_info("auxiliary floppy timer still active\n"); | 4486 | pr_info("auxiliary floppy timer still active\n"); |
4495 | if (work_pending(&floppy_work)) | 4487 | if (work_pending(&floppy_work)) |
4496 | pr_info("work still pending\n"); | 4488 | pr_info("work still pending\n"); |
@@ -4560,8 +4552,9 @@ static void __exit floppy_module_exit(void) | |||
4560 | put_disk(disks[drive]); | 4552 | put_disk(disks[drive]); |
4561 | } | 4553 | } |
4562 | 4554 | ||
4563 | del_timer_sync(&fd_timeout); | 4555 | cancel_delayed_work_sync(&fd_timeout); |
4564 | del_timer_sync(&fd_timer); | 4556 | cancel_delayed_work_sync(&fd_timer); |
4557 | destroy_workqueue(floppy_wq); | ||
4565 | 4558 | ||
4566 | if (atomic_read(&usage_count)) | 4559 | if (atomic_read(&usage_count)) |
4567 | floppy_release_irq_and_dma(); | 4560 | floppy_release_irq_and_dma(); |