[PATCH 02/10] net2280: use helper functions to determine endpoint type and direction

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

 



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/net2280.c |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 9498be8..787456d 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -195,15 +195,14 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 
 	/* set type, direction, address; reset fifo counters */
 	writel ((1 << FIFO_FLUSH), &ep->regs->ep_stat);
-	tmp = (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK);
-	if (tmp == USB_ENDPOINT_XFER_INT) {
+        if (usb_endpoint_xfer_int(desc)) {
 		/* erratum 0105 workaround prevents hs NYET */
 		if (dev->chiprev == 0100
 				&& dev->gadget.speed == USB_SPEED_HIGH
-				&& !(desc->bEndpointAddress & USB_DIR_IN))
+                    && usb_endpoint_dir_out(desc))
 			writel ((1 << CLEAR_NAK_OUT_PACKETS_MODE),
 				&ep->regs->ep_rsp);
-	} else if (tmp == USB_ENDPOINT_XFER_BULK) {
+	} else if (usb_endpoint_xfer_bulk(desc)) {
 		/* catch some particularly blatant driver bugs */
 		if ((dev->gadget.speed == USB_SPEED_HIGH
 					&& max != 512)
@@ -213,7 +212,9 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 			return -ERANGE;
 		}
 	}
-	ep->is_iso = (tmp == USB_ENDPOINT_XFER_ISOC) ? 1 : 0;
+        ep->is_iso = usb_endpoint_xfer_isoc(desc);
+
+        tmp = usb_endpoint_type(desc);
 	tmp <<= ENDPOINT_TYPE;
 	tmp |= desc->bEndpointAddress;
 	tmp |= (4 << ENDPOINT_BYTE_COUNT);	/* default full fifo lines */
@@ -221,7 +222,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 	wmb ();
 
 	/* for OUT transfers, block the rx fifo until a read is posted */
-	ep->is_in = (tmp & USB_DIR_IN) != 0;
+        ep->is_in = usb_endpoint_dir_in(desc);
 	if (!ep->is_in)
 		writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
 	else if (dev->pdev->device != 0x2280) {
@@ -253,7 +254,7 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
 		 * advance the queue; do it pio-style, by hand.
 		 * NOTE erratum 0112 workaround #2
 		 */
-		if ((desc->bEndpointAddress & USB_DIR_IN) == 0) {
+                if (usb_endpoint_dir_out(desc)) {
 			tmp = (1 << SHORT_PACKET_TRANSFERRED_INTERRUPT_ENABLE);
 			writel (tmp, &ep->regs->ep_irqenb);
 
@@ -1230,8 +1231,7 @@ net2280_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
 		return -EINVAL;
 	if (!ep->dev->driver || ep->dev->gadget.speed == USB_SPEED_UNKNOWN)
 		return -ESHUTDOWN;
-	if (ep->desc /* not ep0 */ && (ep->desc->bmAttributes & 0x03)
-						== USB_ENDPOINT_XFER_ISOC)
+        if (ep->desc /* not ep0 */ && usb_endpoint_xfer_isoc(ep->desc))
 		return -EINVAL;
 
 	spin_lock_irqsave (&ep->dev->lock, flags);
@@ -1619,13 +1619,12 @@ show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
 			d = ep->desc;
 			if (!d)
 				continue;
-			t = d->bEndpointAddress;
 			t = scnprintf (next, size,
 				"\n%s (ep%d%s-%s) max %04x %s fifo %d\n",
-				ep->ep.name, t & USB_ENDPOINT_NUMBER_MASK,
-				(t & USB_DIR_IN) ? "in" : "out",
+                                       ep->ep.name, usb_endpoint_number(d),
+                                       usb_endpoint_dir_in(d) ? "in" : "out",
 				({ char *val;
-				 switch (d->bmAttributes & 0x03) {
+                                        switch (usb_endpoint_type(d)) {
 				 case USB_ENDPOINT_XFER_BULK:
 					val = "bulk"; break;
 				 case USB_ENDPOINT_XFER_INT:
-- 
1.6.2.1

--
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