diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-08-02 23:04:52 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-13 01:55:01 +0400 |
commit | d617bc83ff48ebf0df253605529d8b3bef15773a (patch) | |
tree | 15bc0597e795a5dd1cd5c683a052f5a116442ba8 /drivers/usb/core/urb.c | |
parent | 18ea5d00d05fa6300606f0711748016c95fb26dc (diff) | |
download | linux-d617bc83ff48ebf0df253605529d8b3bef15773a.tar.xz |
USB: cleanup for previous patches
This patch (as951) cleans up a few loose ends from earlier patches.
Redundant checks for non-NULL urb->dev are removed, as are checks of
urb->dev->bus (which can never be NULL). Conversely, a check for
non-NULL urb->ep is added to the unlink paths.
A homegrown round-down-to-power-of-2 loop is simplified by using the
ilog2 routine. The comparison in usb_urb_dir_in() is made more
transparent.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/urb.c')
-rw-r--r-- | drivers/usb/core/urb.c | 13 |
1 files changed, 7 insertions, 6 deletions
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 @@ #include <linux/bitops.h> #include <linux/slab.h> #include <linux/init.h> +#include <linux/log2.h> #include <linux/usb.h> #include <linux/wait.h> #include "hcd.h" @@ -441,10 +442,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) default: return -EINVAL; } - /* power of two? */ - while (max > urb->interval) - max >>= 1; - urb->interval = max; + /* Round down to a power of 2, no more than max */ + urb->interval = min(max, 1 << ilog2(urb->interval)); } return usb_hcd_submit_urb(urb, mem_flags); @@ -513,8 +512,10 @@ int usb_unlink_urb(struct urb *urb) { if (!urb) return -EINVAL; - if (!(urb->dev && urb->dev->bus)) + if (!urb->dev) return -ENODEV; + if (!urb->ep) + return -EIDRM; return usb_hcd_unlink_urb(urb, -ECONNRESET); } @@ -541,7 +542,7 @@ int usb_unlink_urb(struct urb *urb) void usb_kill_urb(struct urb *urb) { might_sleep(); - if (!(urb && urb->dev && urb->dev->bus)) + if (!(urb && urb->dev && urb->ep)) return; spin_lock_irq(&urb->lock); ++urb->reject; |