summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2010-04-30 13:11:29 -0600
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-20 13:21:41 -0700
commitfe54b058de9d1df5fef9e2a559651f4b7c9f04b1 (patch)
tree9ed1f427416478e8832f5ca67c17bd8433a87630
parentb18a23495fd4492081a61373fc3ef9f5c59e094a (diff)
downloadop-kernel-dev-fe54b058de9d1df5fef9e2a559651f4b7c9f04b1.zip
op-kernel-dev-fe54b058de9d1df5fef9e2a559651f4b7c9f04b1.tar.gz
USB: Add a usb_pipe_endpoint() convenience function
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>
-rw-r--r--drivers/usb/core/message.c3
-rw-r--r--drivers/usb/core/urb.c3
-rw-r--r--include/linux/usb.h8
3 files changed, 10 insertions, 4 deletions
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 79d1cdf..d8329eb 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -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;
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index a760e46..7c05555 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -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;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 1eb4762..fd7d61e 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -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
OpenPOWER on IntegriCloud