]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb_kbd.c
dm: exynos: gpio: Convert to driver model
[karo-tx-uboot.git] / common / usb_kbd.c
index 0b77c16c5ffc5c05cef1137900ff8caf8b565528..fdc083c70cf9952ec000429355b605b2ec4ff43c 100644 (file)
@@ -8,6 +8,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <errno.h>
 #include <malloc.h>
 #include <stdio_dev.h>
 #include <asm/byteorder.h>
@@ -170,11 +171,12 @@ static void usb_kbd_setled(struct usb_device *dev)
 {
        struct usb_interface *iface = &dev->config.if_desc[0];
        struct usb_kbd_pdata *data = dev->privptr;
-       uint32_t leds = data->flags & USB_KBD_LEDMASK;
+       ALLOC_ALIGN_BUFFER(uint32_t, leds, 1, USB_DMA_MINALIGN);
 
+       *leds = data->flags & USB_KBD_LEDMASK;
        usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
                USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-               0x200, iface->desc.bInterfaceNumber, (void *)&leds, 1, 0);
+               0x200, iface->desc.bInterfaceNumber, leds, 1, 0);
 }
 
 #define CAPITAL_MASK   0x20
@@ -360,7 +362,7 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev)
 }
 
 /* test if a character is in the queue */
-static int usb_kbd_testc(void)
+static int usb_kbd_testc(struct stdio_dev *sdev)
 {
        struct stdio_dev *dev;
        struct usb_device *usb_kbd_dev;
@@ -386,7 +388,7 @@ static int usb_kbd_testc(void)
 }
 
 /* gets the character from the queue */
-static int usb_kbd_getc(void)
+static int usb_kbd_getc(struct stdio_dev *sdev)
 {
        struct stdio_dev *dev;
        struct usb_device *usb_kbd_dev;
@@ -488,7 +490,7 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum)
 /* Search for keyboard and register it if found. */
 int drv_usb_kbd_init(void)
 {
-       struct stdio_dev usb_kbd_dev, *old_dev;
+       struct stdio_dev usb_kbd_dev;
        struct usb_device *dev;
        char *stdinname = getenv("stdin");
        int error, i;
@@ -507,23 +509,11 @@ int drv_usb_kbd_init(void)
                if (usb_kbd_probe(dev, 0) != 1)
                        continue;
 
-               /* We found a keyboard, check if it is already registered. */
-               debug("USB KBD: found set up device.\n");
-               old_dev = stdio_get_by_name(DEVNAME);
-               if (old_dev) {
-                       /* Already registered, just return ok. */
-                       debug("USB KBD: is already registered.\n");
-                       usb_kbd_deregister();
-                       return 1;
-               }
-
                /* Register the keyboard */
                debug("USB KBD: register.\n");
                memset(&usb_kbd_dev, 0, sizeof(struct stdio_dev));
                strcpy(usb_kbd_dev.name, DEVNAME);
                usb_kbd_dev.flags =  DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
-               usb_kbd_dev.putc = NULL;
-               usb_kbd_dev.puts = NULL;
                usb_kbd_dev.getc = usb_kbd_getc;
                usb_kbd_dev.tstc = usb_kbd_testc;
                usb_kbd_dev.priv = (void *)dev;
@@ -557,10 +547,14 @@ int drv_usb_kbd_init(void)
 }
 
 /* Deregister the keyboard. */
-int usb_kbd_deregister(void)
+int usb_kbd_deregister(int force)
 {
 #ifdef CONFIG_SYS_STDIO_DEREGISTER
-       return stdio_deregister(DEVNAME);
+       int ret = stdio_deregister(DEVNAME, force);
+       if (ret && ret != -ENODEV)
+               return ret;
+
+       return 0;
 #else
        return 1;
 #endif