diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2010-06-15 07:21:11 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:15:41 -0400 |
commit | b862f26fe17df273167bd47df79e8742a1bf101c (patch) | |
tree | 7bd31baa632893b980cab3f28b04ced0b5b5079b /drivers/block | |
parent | 21af5448042a0962fb1df13a310bb363a8f6a8dc (diff) |
floppy: use wait_event_interruptible
Convert wait loops to use wait_event_ macros.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/floppy.c | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index fd7085aa999f..3fdceda85735 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -514,8 +514,6 @@ static unsigned long fdc_busy; | |||
514 | static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); | 514 | static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); |
515 | static DECLARE_WAIT_QUEUE_HEAD(command_done); | 515 | static DECLARE_WAIT_QUEUE_HEAD(command_done); |
516 | 516 | ||
517 | #define NO_SIGNAL (!interruptible || !signal_pending(current)) | ||
518 | |||
519 | /* Errors during formatting are counted here. */ | 517 | /* Errors during formatting are counted here. */ |
520 | static int format_errors; | 518 | static int format_errors; |
521 | 519 | ||
@@ -858,36 +856,15 @@ static void set_fdc(int drive) | |||
858 | } | 856 | } |
859 | 857 | ||
860 | /* locks the driver */ | 858 | /* locks the driver */ |
861 | static int _lock_fdc(int drive, bool interruptible, int line) | 859 | static int lock_fdc(int drive, bool interruptible) |
862 | { | 860 | { |
863 | if (atomic_read(&usage_count) == 0) { | 861 | if (WARN(atomic_read(&usage_count) == 0, |
864 | pr_err("Trying to lock fdc while usage count=0 at line %d\n", | 862 | "Trying to lock fdc while usage count=0\n")) |
865 | line); | ||
866 | return -1; | 863 | return -1; |
867 | } | ||
868 | 864 | ||
869 | if (test_and_set_bit(0, &fdc_busy)) { | 865 | if (wait_event_interruptible(fdc_wait, !test_and_set_bit(0, &fdc_busy))) |
870 | DECLARE_WAITQUEUE(wait, current); | 866 | return -EINTR; |
871 | add_wait_queue(&fdc_wait, &wait); | ||
872 | |||
873 | for (;;) { | ||
874 | set_current_state(TASK_INTERRUPTIBLE); | ||
875 | |||
876 | if (!test_and_set_bit(0, &fdc_busy)) | ||
877 | break; | ||
878 | |||
879 | schedule(); | ||
880 | |||
881 | if (!NO_SIGNAL) { | ||
882 | remove_wait_queue(&fdc_wait, &wait); | ||
883 | return -EINTR; | ||
884 | } | ||
885 | } | ||
886 | 867 | ||
887 | set_current_state(TASK_RUNNING); | ||
888 | remove_wait_queue(&fdc_wait, &wait); | ||
889 | flush_scheduled_work(); | ||
890 | } | ||
891 | command_status = FD_COMMAND_NONE; | 868 | command_status = FD_COMMAND_NONE; |
892 | 869 | ||
893 | __reschedule_timeout(drive, "lock fdc"); | 870 | __reschedule_timeout(drive, "lock fdc"); |
@@ -895,9 +872,6 @@ static int _lock_fdc(int drive, bool interruptible, int line) | |||
895 | return 0; | 872 | return 0; |
896 | } | 873 | } |
897 | 874 | ||
898 | #define lock_fdc(drive, interruptible) \ | ||
899 | _lock_fdc(drive, interruptible, __LINE__) | ||
900 | |||
901 | /* unlocks the driver */ | 875 | /* unlocks the driver */ |
902 | static void unlock_fdc(void) | 876 | static void unlock_fdc(void) |
903 | { | 877 | { |
@@ -2015,25 +1989,10 @@ static int wait_til_done(void (*handler)(void), bool interruptible) | |||
2015 | 1989 | ||
2016 | schedule_bh(handler); | 1990 | schedule_bh(handler); |
2017 | 1991 | ||
2018 | if (command_status < 2 && NO_SIGNAL) { | 1992 | if (interruptible) |
2019 | DECLARE_WAITQUEUE(wait, current); | 1993 | wait_event_interruptible(command_done, command_status >= 2); |
2020 | 1994 | else | |
2021 | add_wait_queue(&command_done, &wait); | 1995 | wait_event(command_done, command_status >= 2); |
2022 | for (;;) { | ||
2023 | set_current_state(interruptible ? | ||
2024 | TASK_INTERRUPTIBLE : | ||
2025 | TASK_UNINTERRUPTIBLE); | ||
2026 | |||
2027 | if (command_status >= 2 || !NO_SIGNAL) | ||
2028 | break; | ||
2029 | |||
2030 | is_alive(__func__, ""); | ||
2031 | schedule(); | ||
2032 | } | ||
2033 | |||
2034 | set_current_state(TASK_RUNNING); | ||
2035 | remove_wait_queue(&command_done, &wait); | ||
2036 | } | ||
2037 | 1996 | ||
2038 | if (command_status < 2) { | 1997 | if (command_status < 2) { |
2039 | cancel_activity(); | 1998 | cancel_activity(); |