diff options
-rw-r--r-- | drivers/usb/core/hcd.c | 5 | ||||
-rw-r--r-- | drivers/usb/core/urb.c | 13 | ||||
-rw-r--r-- | include/linux/usb.h | 2 |
3 files changed, 8 insertions, 12 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 739c5e0aa3b8..47a055a2acf5 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -1074,11 +1074,6 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) | |||
1074 | struct list_head *tmp; | 1074 | struct list_head *tmp; |
1075 | int retval; | 1075 | int retval; |
1076 | 1076 | ||
1077 | if (!urb) | ||
1078 | return -EINVAL; | ||
1079 | if (!urb->dev || !urb->dev->bus) | ||
1080 | return -ENODEV; | ||
1081 | |||
1082 | /* | 1077 | /* |
1083 | * we contend for urb->status with the hcd core, | 1078 | * we contend for urb->status with the hcd core, |
1084 | * which changes it while returning the urb. | 1079 | * which changes it while returning the urb. |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 1acca8696bcd..19f5f66c2733 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <linux/bitops.h> | 3 | #include <linux/bitops.h> |
4 | #include <linux/slab.h> | 4 | #include <linux/slab.h> |
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/log2.h> | ||
6 | #include <linux/usb.h> | 7 | #include <linux/usb.h> |
7 | #include <linux/wait.h> | 8 | #include <linux/wait.h> |
8 | #include "hcd.h" | 9 | #include "hcd.h" |
@@ -441,10 +442,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
441 | default: | 442 | default: |
442 | return -EINVAL; | 443 | return -EINVAL; |
443 | } | 444 | } |
444 | /* power of two? */ | 445 | /* Round down to a power of 2, no more than max */ |
445 | while (max > urb->interval) | 446 | urb->interval = min(max, 1 << ilog2(urb->interval)); |
446 | max >>= 1; | ||
447 | urb->interval = max; | ||
448 | } | 447 | } |
449 | 448 | ||
450 | return usb_hcd_submit_urb(urb, mem_flags); | 449 | return usb_hcd_submit_urb(urb, mem_flags); |
@@ -513,8 +512,10 @@ int usb_unlink_urb(struct urb *urb) | |||
513 | { | 512 | { |
514 | if (!urb) | 513 | if (!urb) |
515 | return -EINVAL; | 514 | return -EINVAL; |
516 | if (!(urb->dev && urb->dev->bus)) | 515 | if (!urb->dev) |
517 | return -ENODEV; | 516 | return -ENODEV; |
517 | if (!urb->ep) | ||
518 | return -EIDRM; | ||
518 | return usb_hcd_unlink_urb(urb, -ECONNRESET); | 519 | return usb_hcd_unlink_urb(urb, -ECONNRESET); |
519 | } | 520 | } |
520 | 521 | ||
@@ -541,7 +542,7 @@ int usb_unlink_urb(struct urb *urb) | |||
541 | void usb_kill_urb(struct urb *urb) | 542 | void usb_kill_urb(struct urb *urb) |
542 | { | 543 | { |
543 | might_sleep(); | 544 | might_sleep(); |
544 | if (!(urb && urb->dev && urb->dev->bus)) | 545 | if (!(urb && urb->dev && urb->ep)) |
545 | return; | 546 | return; |
546 | spin_lock_irq(&urb->lock); | 547 | spin_lock_irq(&urb->lock); |
547 | ++urb->reject; | 548 | ++urb->reject; |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 019ae963a9fe..a51f34e80572 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -1395,7 +1395,7 @@ extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, | |||
1395 | */ | 1395 | */ |
1396 | static inline int usb_urb_dir_in(struct urb *urb) | 1396 | static inline int usb_urb_dir_in(struct urb *urb) |
1397 | { | 1397 | { |
1398 | return (urb->transfer_flags & URB_DIR_MASK) != URB_DIR_OUT; | 1398 | return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN; |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | /** | 1401 | /** |