Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d617bc83ff48ebf0df253605529d8b3bef15773a
Commit:     d617bc83ff48ebf0df253605529d8b3bef15773a
Parent:     18ea5d00d05fa6300606f0711748016c95fb26dc
Author:     Alan Stern <[EMAIL PROTECTED]>
AuthorDate: Thu Aug 2 15:04:52 2007 -0400
Committer:  Greg Kroah-Hartman <[EMAIL PROTECTED]>
CommitDate: Fri Oct 12 14:55:01 2007 -0700

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
---
 drivers/usb/core/hcd.c |    5 -----
 drivers/usb/core/urb.c |   13 +++++++------
 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 739c5e0..47a055a 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)
        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.
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 1acca86..19f5f66 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;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 019ae96..a51f34e 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,
  */
 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;
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to