Skip to content

Commit b785ea7

Browse files
author
Felipe Balbi
committed
usb: gadget: composite: fix ep->maxburst initialization
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>
1 parent fbcaba0 commit b785ea7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
414414

415415
params.param0 = DWC3_DEPCFG_EP_TYPE(usb_endpoint_type(desc))
416416
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc))
417-
| DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst);
417+
| DWC3_DEPCFG_BURST_SIZE(dep->endpoint.maxburst - 1);
418418

419419
params.param1 = DWC3_DEPCFG_XFER_COMPLETE_EN
420420
| DWC3_DEPCFG_XFER_NOT_READY_EN;

drivers/usb/gadget/composite.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ int config_ep_by_speed(struct usb_gadget *g,
117117
struct usb_function *f,
118118
struct usb_ep *_ep)
119119
{
120+
struct usb_composite_dev *cdev = get_gadget_data(g);
120121
struct usb_endpoint_descriptor *chosen_desc = NULL;
121122
struct usb_descriptor_header **speed_desc = NULL;
122123

@@ -180,10 +181,12 @@ int config_ep_by_speed(struct usb_gadget *g,
180181
_ep->mult = comp_desc->bmAttributes & 0x3;
181182
case USB_ENDPOINT_XFER_BULK:
182183
case USB_ENDPOINT_XFER_INT:
183-
_ep->maxburst = comp_desc->bMaxBurst;
184+
_ep->maxburst = comp_desc->bMaxBurst + 1;
184185
break;
185186
default:
186-
/* Do nothing for control endpoints */
187+
if (comp_desc->bMaxBurst != 0)
188+
ERROR(cdev, "ep0 bMaxBurst must be 0\n");
189+
_ep->maxburst = 1;
187190
break;
188191
}
189192
}

0 commit comments

Comments
 (0)