Commit 25fbf96b24fd3fe0a5252c374b445be32f42b0c8

Authored by Stephen Warren
Committed by Lukasz Majewski
1 parent c4d0e85604

USB: gadget: save driver name before registering it

g_dnl_register() currently first attempts to register a composite
driver by name, and then saves the driver name once it's registered.
Internally to the registration code, g_dnl_do_config() is called and
attempts to compare the composite device's name with the list of known
device names. This fails since the composite device's name has not yet
been stored. This means that the first time "ums 0 0" is run, it fails,
but subsequent attempts succeed.

Re-order the name-saving and registration code to solve this.

Fixes: e5b834e07f51 ("USB: gadget: added a saner gadget downloader registration API")
Signed-off-by: Stephen Warren <swarren@nvidia.com>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/usb/gadget/g_dnl.c
... ... @@ -245,11 +245,12 @@
245 245 */
246 246 int g_dnl_register(const char *name)
247 247 {
248   - int ret = usb_composite_register(&g_dnl_driver);
  248 + int ret;
249 249  
250 250 debug("%s: g_dnl_driver.name = %s\n", __func__, name);
251 251 g_dnl_driver.name = name;
252 252  
  253 + ret = usb_composite_register(&g_dnl_driver);
253 254 if (ret) {
254 255 printf("%s: failed!, error: %d\n", __func__, ret);
255 256 return ret;