Re: [PATCH 05/10] USB endpoint autoconfiguration: use helper functions to determine endpoint type and direction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El Wed, Apr 15, 2009 at 02:27:28PM -0700 David Brownell ha dit:

> On Wednesday 15 April 2009, Matthias Kaehlcke wrote:
> > Use helper functions to determine the type and direction of an endpoint instead
> > of fiddling with bEndpointAddress and bmAttributes
> > 
> > Signed-off-by: Matthias Kaehlcke <matthias@xxxxxxxxxxxx>
> 
> This one I don't much like ... does it shrink the code?
> 
> It only touched bmAttributes once before your changes, and
> afterwards it does so many times.

my purpose was to improve readability (very slightly ...), but i agree
with your concerns. below a new version of the patch that addresses
them

--
Use helper functions to determine the type and direction of an endpoint instead
of fiddling with bEndpointAddress and bmAttributes

Signed-off-by: Matthias Kaehlcke <matthias@xxxxxxxxxxxx>
---
 drivers/usb/gadget/epautoconf.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index cd0914e..6c8887a 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -75,7 +75,7 @@ ep_matches (
 		return 0;
 
 	/* only support ep0 for portable CONTROL traffic */
-	type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+	type = usb_endpoint_type(desc);
 	if (USB_ENDPOINT_XFER_CONTROL == type)
 		return 0;
 
@@ -118,7 +118,7 @@ ep_matches (
 		/* direction-restriction:  "..in-..", "out-.." */
 		tmp--;
 		if (!isdigit (*tmp)) {
-			if (desc->bEndpointAddress & USB_DIR_IN) {
+			if (usb_endpoint_dir_in(desc)) {
 				if ('n' != *tmp)
 					return 0;
 			} else {
@@ -164,7 +164,7 @@ ep_matches (
 		u8	num = simple_strtoul (&ep->name [2], NULL, 10);
 		desc->bEndpointAddress |= num;
 #ifdef	MANY_ENDPOINTS
-	} else if (desc->bEndpointAddress & USB_DIR_IN) {
+	} else if (usb_endpoint_dir_in(desc)) {
 		if (++in_epnum > 15)
 			return 0;
 		desc->bEndpointAddress = USB_DIR_IN | in_epnum;
@@ -237,7 +237,7 @@ struct usb_ep * __init usb_ep_autoconfig (
 	struct usb_ep	*ep;
 	u8		type;
 
-	type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+	type = usb_endpoint_type(desc);
 
 	/* First, apply chip-specific "best usage" knowledge.
 	 * This might make a good usb_gadget_ops hook ...
@@ -258,7 +258,7 @@ struct usb_ep * __init usb_ep_autoconfig (
 			if (ep && ep_matches (gadget, ep, desc))
 				return ep;
 		} else if (USB_ENDPOINT_XFER_BULK == type
-				&& (USB_DIR_IN & desc->bEndpointAddress)) {
+				&& usb_endpoint_dir_in(desc)) {
 			/* DMA may be available */
 			ep = find_ep (gadget, "ep2-bulk");
 			if (ep && ep_matches (gadget, ep, desc))

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

            Nothing is more despicable than respect based on fear
                              (Albert Camus)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux