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>
This commit is contained in:
parent
18ea5d00d0
commit
d617bc83ff
|
@ -1074,11 +1074,6 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!urb)
|
|
||||||
return -EINVAL;
|
|
||||||
if (!urb->dev || !urb->dev->bus)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we contend for urb->status with the hcd core,
|
* we contend for urb->status with the hcd core,
|
||||||
* which changes it while returning the urb.
|
* which changes it while returning the urb.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
#include <linux/log2.h>
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
#include "hcd.h"
|
#include "hcd.h"
|
||||||
|
@ -441,10 +442,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
/* power of two? */
|
/* Round down to a power of 2, no more than max */
|
||||||
while (max > urb->interval)
|
urb->interval = min(max, 1 << ilog2(urb->interval));
|
||||||
max >>= 1;
|
|
||||||
urb->interval = max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return usb_hcd_submit_urb(urb, mem_flags);
|
return usb_hcd_submit_urb(urb, mem_flags);
|
||||||
|
@ -513,8 +512,10 @@ int usb_unlink_urb(struct urb *urb)
|
||||||
{
|
{
|
||||||
if (!urb)
|
if (!urb)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!(urb->dev && urb->dev->bus))
|
if (!urb->dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
if (!urb->ep)
|
||||||
|
return -EIDRM;
|
||||||
return usb_hcd_unlink_urb(urb, -ECONNRESET);
|
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)
|
void usb_kill_urb(struct urb *urb)
|
||||||
{
|
{
|
||||||
might_sleep();
|
might_sleep();
|
||||||
if (!(urb && urb->dev && urb->dev->bus))
|
if (!(urb && urb->dev && urb->ep))
|
||||||
return;
|
return;
|
||||||
spin_lock_irq(&urb->lock);
|
spin_lock_irq(&urb->lock);
|
||||||
++urb->reject;
|
++urb->reject;
|
||||||
|
|
|
@ -1395,7 +1395,7 @@ extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
|
||||||
*/
|
*/
|
||||||
static inline int usb_urb_dir_in(struct urb *urb)
|
static inline int usb_urb_dir_in(struct urb *urb)
|
||||||
{
|
{
|
||||||
return (urb->transfer_flags & URB_DIR_MASK) != URB_DIR_OUT;
|
return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue