u-boot-dfu-20250425

Usb gadget:
- Fix ACM gadget release
- Allow ACM gadget restart after releasing it
- Add 'enabled' flag to usb_ep structure

DFU:
- Fix alt buffer clearing for DeveloperBox board
This commit is contained in:
Tom Rini
2025-04-24 10:44:17 -06:00
3 changed files with 30 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ void set_dfu_alt_info(char *interface, char *devstr)
struct mtd_info *mtd; struct mtd_info *mtd;
int ret; int ret;
memset(buf, 0, sizeof(buf)); memset(buf, 0, DFU_ALT_BUF_LEN);
mtd_probe_devices(); mtd_probe_devices();

View File

@@ -238,18 +238,21 @@ static int acm_bind(struct usb_configuration *c, struct usb_function *f)
return -ENODEV; return -ENODEV;
f_acm->ep_in = ep; f_acm->ep_in = ep;
ep->driver_data = c->cdev; /* claim */
ep = usb_ep_autoconfig(gadget, &acm_fs_out_desc); ep = usb_ep_autoconfig(gadget, &acm_fs_out_desc);
if (!ep) if (!ep)
return -ENODEV; return -ENODEV;
f_acm->ep_out = ep; f_acm->ep_out = ep;
ep->driver_data = c->cdev; /* claim */
ep = usb_ep_autoconfig(gadget, &acm_fs_notify_desc); ep = usb_ep_autoconfig(gadget, &acm_fs_notify_desc);
if (!ep) if (!ep)
return -ENODEV; return -ENODEV;
f_acm->ep_notify = ep; f_acm->ep_notify = ep;
ep->driver_data = c->cdev; /* claim */
if (gadget_is_dualspeed(gadget)) { if (gadget_is_dualspeed(gadget)) {
/* Assume endpoint addresses are the same for both speeds */ /* Assume endpoint addresses are the same for both speeds */
@@ -660,6 +663,7 @@ static int acm_stdio_stop(struct stdio_dev *dev)
{ {
g_dnl_unregister(); g_dnl_unregister();
g_dnl_clear_detach(); g_dnl_clear_detach();
dev->priv = NULL;
return 0; return 0;
} }

View File

@@ -179,6 +179,7 @@ struct usb_ep {
const struct usb_ep_ops *ops; const struct usb_ep_ops *ops;
struct list_head ep_list; struct list_head ep_list;
struct usb_ep_caps caps; struct usb_ep_caps caps;
bool enabled;
unsigned maxpacket:16; unsigned maxpacket:16;
unsigned maxpacket_limit:16; unsigned maxpacket_limit:16;
unsigned max_streams:16; unsigned max_streams:16;
@@ -230,7 +231,18 @@ static inline void usb_ep_set_maxpacket_limit(struct usb_ep *ep,
static inline int usb_ep_enable(struct usb_ep *ep, static inline int usb_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc) const struct usb_endpoint_descriptor *desc)
{ {
return ep->ops->enable(ep, desc); int ret;
if (ep->enabled)
return 0;
ret = ep->ops->enable(ep, desc);
if (ret)
return ret;
ep->enabled = true;
return 0;
} }
/** /**
@@ -247,7 +259,18 @@ static inline int usb_ep_enable(struct usb_ep *ep,
*/ */
static inline int usb_ep_disable(struct usb_ep *ep) static inline int usb_ep_disable(struct usb_ep *ep)
{ {
return ep->ops->disable(ep); int ret;
if (!ep->enabled)
return 0;
ret = ep->ops->disable(ep);
if (ret)
return ret;
ep->enabled = false;
return 0;
} }
/** /**