diff options
author | Arnd Bergmann <arnd@arndb.de> | 2014-01-02 13:07:53 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-08 15:29:52 -0800 |
commit | eb831743f2b43253b0aec40f66a95fdcf8f178cc (patch) | |
tree | c1b2787fa11d6bfe36a9964d3db7782fbe789b16 /drivers/char | |
parent | 83ce07411dc2316aaaf95a0f193fa2fd76e2e739 (diff) |
char: nwbutton: open-code interruptible_sleep_on
The nwbutton driver uses interruptible_sleep_on to wait for buttons
getting pressed after we enter the read() function, which is inherently
racy and cannot be fixed by using wait_event without changing the
driver's user space interface.
Instead, this patch just uses an open-coded variant of the same
interruptible_sleep_on() call, so the driver behavior doesn't change
but we remove the sleep_on family from the kernel.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/nwbutton.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/char/nwbutton.c b/drivers/char/nwbutton.c index 1fd00dc06897..76c490fa0511 100644 --- a/drivers/char/nwbutton.c +++ b/drivers/char/nwbutton.c @@ -168,7 +168,10 @@ static irqreturn_t button_handler (int irq, void *dev_id) static int button_read (struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { - interruptible_sleep_on (&button_wait_queue); + DEFINE_WAIT(wait); + prepare_to_wait(&button_wait_queue, &wait, TASK_INTERRUPTIBLE); + schedule(); + finish_wait(&button_wait_queue, &wait); return (copy_to_user (buffer, &button_output_buffer, bcount)) ? -EFAULT : bcount; } |