Skip to content

Commit

Permalink
timeout on wait_event when closing
Browse files Browse the repository at this point in the history
because I'm just nervous, that's why...
  • Loading branch information
djpohly committed Aug 22, 2014
1 parent bbbb54f commit 60c4063
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mod/piuio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/errno.h>
#include <linux/bitops.h>
#include <linux/wait.h>
#include <linux/jiffies.h>
#include <linux/input.h>
#include <linux/usb.h>
#include <linux/usb/input.h>
Expand Down Expand Up @@ -248,8 +249,10 @@ static void piuio_close(struct input_dev *dev)
/* Stop polling, but wait for the last requests to complete */
usb_block_urb(piu->in);
usb_block_urb(piu->out);
wait_event(piu->shutdown_wait, atomic_read(&piu->in->use_count) == 0 &&
atomic_read(&piu->out->use_count) == 0);
wait_event_timeout(piu->shutdown_wait,
atomic_read(&piu->in->use_count) == 0 &&
atomic_read(&piu->out->use_count) == 0,
msecs_to_jiffies(5));
usb_unblock_urb(piu->in);
usb_unblock_urb(piu->out);

Expand Down

0 comments on commit 60c4063

Please sign in to comment.