USB: Add a usb_pipe_endpoint() convenience function
authorMatthew Wilcox <willy@linux.intel.com>
Fri, 30 Apr 2010 19:11:29 +0000 (13:11 -0600)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 20 May 2010 20:21:41 +0000 (13:21 -0700)
Converting a pipe number to a struct usb_host_endpoint pointer is a little
messy.  Introduce a new convenience function to hide the mess.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/message.c
drivers/usb/core/urb.c
include/linux/usb.h

index 79d1cdf4a635764fab6db65a7273b4e5322b4024..d8329eb47d4ffc26cd9f88bea8e466459ce56c1c 100644 (file)
@@ -226,8 +226,7 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
        struct urb *urb;
        struct usb_host_endpoint *ep;
 
-       ep = (usb_pipein(pipe) ? usb_dev->ep_in : usb_dev->ep_out)
-                       [usb_pipeendpoint(pipe)];
+       ep = usb_pipe_endpoint(usb_dev, pipe);
        if (!ep || len < 0)
                return -EINVAL;
 
index a760e46871c5b66fc0f40055df5d1ace8e0b9ec1..7c0555548ac862b9606600c38f9b48a94e144f57 100644 (file)
@@ -308,8 +308,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
         * will be required to set urb->ep directly and we will eliminate
         * urb->pipe.
         */
-       ep = (usb_pipein(urb->pipe) ? dev->ep_in : dev->ep_out)
-                       [usb_pipeendpoint(urb->pipe)];
+       ep = usb_pipe_endpoint(dev, urb->pipe);
        if (!ep)
                return -ENOENT;
 
index 1eb4762d9ea8b3a3ef7c37f92d6aa128b9bc6bb0..fd7d61e58198b5232c68cc2025e723867a52c107 100644 (file)
@@ -1552,6 +1552,14 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
 #define usb_rcvintpipe(dev,endpoint)   \
        ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
 
+static inline struct usb_host_endpoint *
+usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe)
+{
+       struct usb_host_endpoint **eps;
+       eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out;
+       return eps[usb_pipeendpoint(pipe)];
+}
+
 /*-------------------------------------------------------------------------*/
 
 static inline __u16