Commit e5e4746510d140261918aecce2e5e3aa4456f7e9
Committed by
Greg Kroah-Hartman
1 parent
226b3a2e2e
Exists in
master
and in
16 other branches
usb: usbtest: Add timetout to simple_io()
Without a timetout some tests e.g. test_halt() can remain stuck forever. Signed-off-by: Roger Quadros <rogerq@ti.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 11 additions and 3 deletions Side-by-side Diff
drivers/usb/misc/usbtest.c
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | |
11 | 11 | #include <linux/usb.h> |
12 | 12 | |
13 | +#define SIMPLE_IO_TIMEOUT 10000 /* in milliseconds */ | |
13 | 14 | |
14 | 15 | /*-------------------------------------------------------------------------*/ |
15 | 16 | |
... | ... | @@ -366,6 +367,7 @@ |
366 | 367 | int max = urb->transfer_buffer_length; |
367 | 368 | struct completion completion; |
368 | 369 | int retval = 0; |
370 | + unsigned long expire; | |
369 | 371 | |
370 | 372 | urb->context = &completion; |
371 | 373 | while (retval == 0 && iterations-- > 0) { |
... | ... | @@ -378,9 +380,15 @@ |
378 | 380 | if (retval != 0) |
379 | 381 | break; |
380 | 382 | |
381 | - /* NOTE: no timeouts; can't be broken out of by interrupt */ | |
382 | - wait_for_completion(&completion); | |
383 | - retval = urb->status; | |
383 | + expire = msecs_to_jiffies(SIMPLE_IO_TIMEOUT); | |
384 | + if (!wait_for_completion_timeout(&completion, expire)) { | |
385 | + usb_kill_urb(urb); | |
386 | + retval = (urb->status == -ENOENT ? | |
387 | + -ETIMEDOUT : urb->status); | |
388 | + } else { | |
389 | + retval = urb->status; | |
390 | + } | |
391 | + | |
384 | 392 | urb->dev = udev; |
385 | 393 | if (retval == 0 && usb_pipein(urb->pipe)) |
386 | 394 | retval = simple_check_buf(tdev, urb); |