Commit 8038f6d2 authored by Sam Protsenko's avatar Sam Protsenko Committed by Marek Vasut
Browse files

usb: gadget: composite: Correct recovery path for register



In case when usb_composite_register() failed once (for whatever reason),
it will fail further even if all conditions are correct. Example:

    => fastboot 2
    Invalid Controller Index
    couldn't find an available UDC
    g_dnl_register: failed!, error: -19
    exit not allowed from main input shell.

    => fastboot 0
    g_dnl_register: failed!, error: -22
    exit not allowed from main input shell.

Despite that 0 is correct index for USB controller, "fastboot 0" command
will fail, because "composite" structure wasn't cleared properly on
previous fail (on "fastboot 2" command).

This patch fixes that erroneous behavior, allowing us to use composite
even after previous failure.
Signed-off-by: default avatarSam Protsenko <semen.protsenko@linaro.org>
parent 50dc8677
...@@ -1077,6 +1077,8 @@ static struct usb_gadget_driver composite_driver = { ...@@ -1077,6 +1077,8 @@ static struct usb_gadget_driver composite_driver = {
*/ */
int usb_composite_register(struct usb_composite_driver *driver) int usb_composite_register(struct usb_composite_driver *driver)
{ {
int res;
if (!driver || !driver->dev || !driver->bind || composite) if (!driver || !driver->dev || !driver->bind || composite)
return -EINVAL; return -EINVAL;
...@@ -1084,7 +1086,11 @@ int usb_composite_register(struct usb_composite_driver *driver) ...@@ -1084,7 +1086,11 @@ int usb_composite_register(struct usb_composite_driver *driver)
driver->name = "composite"; driver->name = "composite";
composite = driver; composite = driver;
return usb_gadget_register_driver(&composite_driver); res = usb_gadget_register_driver(&composite_driver);
if (res != 0)
composite = NULL;
return res;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment