On Fri, Aug 23, 2024 at 4:54 AM Marek Vasut <ma...@denx.de> wrote: > > I think udc_bind_to_driver() should not call usb_gadget_connect() , that > connect should likely be called by at some later point.
Yes it's more logical, to keep it in disconnected state you prefer modify controllers drivers init (I can do usba_udc and dwc2) or add a disconnect() call ? > I also think > that drivers/usb/gadget/udc/udc-core.c might have to be extended to > provide some way to convert controller struct udevice to struct > usb_gadget , so when e.g. run_usb_dnl_gadget() calls > udc_device_get_by_index() and obtains struct udevice * , it can also get > matching struct usb_gadget * , and call the usb_gadget_connect(). > > What do you think ? I think it's a good idea. If there are multiple gadget controllers (very rare), since usb_gadget_probe_driver() simply takes the first one from udc list, is there a chance that the one to be started is different from the one used by udc_device_get_by_index() ?