usb: gadget: composite: fix ep->maxburst initialization
authorFelipe Balbi <balbi@ti.com>
Wed, 6 Jun 2012 07:20:23 +0000 (10:20 +0300)
committerFelipe Balbi <balbi@ti.com>
Tue, 12 Jun 2012 10:30:25 +0000 (13:30 +0300)
bMaxBurst field on endpoint companion descriptor
is supposed to contain the number of burst minus
1. When passing that to controller drivers, we
should be passing the real number instead (by
incrementing 1).

While doing that, also fix the assumption on
dwc3 that value comes decremented by one.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/composite.c

index 3df1a1973b0559d7bb53fd4ce7eb148d25dff1e7..cc978d65a8081814471676366ced298d68cc7e7b 100644 (file)
@@ -414,7 +414,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
 
        params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc))
                | DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc))
-               | DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst);
+               | DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst - 1);
 
        params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN
                | DWC3_DEPCFG_XFER_NOT_READY_EN;
index 390749bbb0c316119de33dc2aa15d29ec5e37c0f..3f72110da1b0113fd4f1f28243c6315609638010 100644 (file)
@@ -117,6 +117,7 @@ int config_ep_by_speed(struct usb_gadget *g,
                        struct usb_function *f,
                        struct usb_ep *_ep)
 {
+       struct usb_composite_dev        *cdev = get_gadget_data(g);
        struct usb_endpoint_descriptor *chosen_desc = NULL;
        struct usb_descriptor_header **speed_desc = NULL;
 
@@ -180,10 +181,12 @@ ep_found:
                        _ep->mult = comp_desc->bmAttributes & 0x3;
                case USB_ENDPOINT_XFER_BULK:
                case USB_ENDPOINT_XFER_INT:
-                       _ep->maxburst = comp_desc->bMaxBurst;
+                       _ep->maxburst = comp_desc->bMaxBurst + 1;
                        break;
                default:
-                       /* Do nothing for control endpoints */
+                       if (comp_desc->bMaxBurst != 0)
+                               ERROR(cdev, "ep0 bMaxBurst must be 0\n");
+                       _ep->maxburst = 1;
                        break;
                }
        }