struct list_head *tmp;
int retval;
- if (!urb)
- return -EINVAL;
- if (!urb->dev || !urb->dev->bus)
- return -ENODEV;
-
/*
* we contend for urb->status with the hcd core,
* which changes it while returning the urb.
#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"
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);
{
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);
}
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;
*/
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;
}
/**