usb: gadget: composite: Correct recovery path for register
authorSam Protsenko <semen.protsenko@linaro.org>
Tue, 16 Feb 2016 17:59:19 +0000 (19:59 +0200)
committerMarek Vasut <marex@denx.de>
Tue, 1 Mar 2016 13:47:26 +0000 (14:47 +0100)
commit8038f6d2881d58f5322109a2f5ec2de5aaa6fc30
treec5736658a5f81bb4dbb76b3d23e2a9d688d0b934
parent50dc8677d769be6e2b34f49b6c43ad1e977bdc51
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: Sam Protsenko <semen.protsenko@linaro.org>
drivers/usb/gadget/composite.c