More recent versions of usb_ep_autoconfig() use the maxpacket_limit
field from struct usb_ep.

This field has been introduced in the linux kernel via commit
e117e742d310 ("usb: gadget: add "maxpacket_limit" field to struct usb_ep")
And has been ported to U-Boot via commit
747a0a5b387f ("usb: dwc3: gadget: make dwc3 gadget build in uboot")

However, the dwc2 gadget driver was not converted to use
usb_ep_set_maxpacket_limit().
This is harmless for now, but the driver will break once
usb_ep_autoconfig() is updated to a more recent version.

Set maxpacket_limit via the recommended helper function to prepare for
a core gadget update.

Signed-off-by: Mattijs Korpershoek <[email protected]>
---
 drivers/usb/gadget/dwc2_udc_otg.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/dwc2_udc_otg.c 
b/drivers/usb/gadget/dwc2_udc_otg.c
index e475b14b9ac3..9c85383fd62a 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -828,7 +828,6 @@ static struct dwc2_udc memory = {
                .ep = {
                        .name = ep0name,
                        .ops = &dwc2_ep_ops,
-                       .maxpacket = EP0_FIFO_SIZE,
                },
                .dev = &memory,
 
@@ -843,7 +842,6 @@ static struct dwc2_udc memory = {
                .ep = {
                        .name = "ep1in-bulk",
                        .ops = &dwc2_ep_ops,
-                       .maxpacket = EP_FIFO_SIZE,
                },
                .dev = &memory,
 
@@ -858,7 +856,6 @@ static struct dwc2_udc memory = {
                .ep = {
                        .name = "ep2out-bulk",
                        .ops = &dwc2_ep_ops,
-                       .maxpacket = EP_FIFO_SIZE,
                },
                .dev = &memory,
 
@@ -873,7 +870,6 @@ static struct dwc2_udc memory = {
                .ep = {
                        .name = "ep3in-int",
                        .ops = &dwc2_ep_ops,
-                       .maxpacket = EP_FIFO_SIZE,
                },
                .dev = &memory,
 
@@ -893,6 +889,7 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
 {
        struct dwc2_udc *dev = &memory;
        int retval = 0;
+       int i;
 
        debug("%s: %p\n", __func__, pdata);
 
@@ -909,6 +906,10 @@ int dwc2_udc_probe(struct dwc2_plat_otg_data *pdata)
 
        the_controller = dev;
 
+       usb_ep_set_maxpacket_limit(&dev->ep[0].ep, EP0_FIFO_SIZE);
+       for (i = 1; i < DWC2_MAX_ENDPOINTS; i++)
+               usb_ep_set_maxpacket_limit(&dev->ep[i].ep, EP_FIFO_SIZE);
+
        usb_ctrl = memalign(CONFIG_SYS_CACHELINE_SIZE,
                            ROUND(sizeof(struct usb_ctrlrequest),
                                  CONFIG_SYS_CACHELINE_SIZE));

-- 
2.54.0

Reply via email to