summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-01-03 13:50:31 -0700
committerSimon Glass <sjg@chromium.org>2016-01-07 11:28:03 -0700
commit8a8348703081098dcd0b3affd5ee432164d2f535 (patch)
tree3df0c0d40387123c9678dce67c98d10a4e61771d /common
parent70caa97108d790e5779b347a8530b130df9f000a (diff)
downloadu-boot-imx-8a8348703081098dcd0b3affd5ee432164d2f535.zip
u-boot-imx-8a8348703081098dcd0b3affd5ee432164d2f535.tar.gz
u-boot-imx-8a8348703081098dcd0b3affd5ee432164d2f535.tar.bz2
dm: usb: Add a remove() method for USB keyboards
At present USB keyboards are not properly removed with driver model. Add the code to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'common')
-rw-r--r--common/usb_kbd.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index 9617a48..cbb1995 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -611,6 +611,41 @@ static int usb_kbd_probe(struct udevice *dev)
return ret;
}
+static int usb_kbd_remove(struct udevice *dev)
+{
+ struct usb_device *udev = dev_get_parent_priv(dev);
+ struct usb_kbd_pdata *data;
+ struct stdio_dev *sdev;
+ int ret;
+
+ sdev = stdio_get_by_name(DEVNAME);
+ if (!sdev) {
+ ret = -ENXIO;
+ goto err;
+ }
+ data = udev->privptr;
+ if (stdio_deregister_dev(sdev, true)) {
+ ret = -EPERM;
+ goto err;
+ }
+#ifdef CONFIG_CONSOLE_MUX
+ if (iomux_doenv(stdin, getenv("stdin"))) {
+ ret = -ENOLINK;
+ goto err;
+ }
+#endif
+#ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
+ destroy_int_queue(udev, data->intq);
+#endif
+ free(data->new);
+ free(data);
+
+ return 0;
+err:
+ printf("%s: warning, ret=%d", __func__, ret);
+ return ret;
+}
+
static const struct udevice_id usb_kbd_ids[] = {
{ .compatible = "usb-keyboard" },
{ }
@@ -621,6 +656,7 @@ U_BOOT_DRIVER(usb_kbd) = {
.id = UCLASS_KEYBOARD,
.of_match = usb_kbd_ids,
.probe = usb_kbd_probe,
+ .remove = usb_kbd_remove,
};
static const struct usb_device_id kbd_id_table[] = {