usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop()
authorHans de Goede <hdegoede@redhat.com>
Sat, 20 Sep 2014 14:54:35 +0000 (16:54 +0200)
committerMarek Vasut <marex@denx.de>
Mon, 6 Oct 2014 12:50:43 +0000 (14:50 +0200)
commit6e78c74f62ebfa378d1a2f9b83423b23545c28bf
treea1822c0772256b3b6b14ac55a08839b4c5bc40be
parent0ea09dfe873657df47d83d5d4e0090bbf05c6abb
usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop()

We need to call usb_kbd_deregister() before calling usb_stop().

usbkbd's stdio_dev->priv points to the usb_device, and usb_kbd_testc
dereferences usb_device->privptr.

usb_stop zeros usb_device, leaving usb_device->privptr NULL, causing
bad things (tm) to happen once control returns to the main loop and
usb_kbd_testc gets called.

Calling usb_kbd_deregister() avoids this. Note that we do not allow
the "usb reset" to continue when the deregister fails. This will be fixed
in a later patch.

For the same reasons always fail "usb stop" if the usb_kbd_deregister() fails,
even in the force path. This can happen when CONFIG_SYS_STDIO_DEREGISTER is
not set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
common/cmd_usb.c