]> git.sur5r.net Git - u-boot/blobdiff - common/usb_kbd.c
Move do_irqinfo() to common/cmd_irq.c
[u-boot] / common / usb_kbd.c
index 108bd60f952950feed617db46a8d079e34affc32..b458d77283a2497ebe1c86f31d20af5a9ed6f3d7 100644 (file)
@@ -25,7 +25,7 @@
  *
  */
 #include <common.h>
-#include <devices.h>
+#include <stdio_dev.h>
 #include <asm/byteorder.h>
 
 #include <usb.h>
@@ -36,7 +36,7 @@
  * are switched to the serial port, else the settings in the
  * environment are used
  */
-#ifdef CFG_CONSOLE_OVERWRITE_ROUTINE
+#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
 extern int overwrite_console (void);
 #else
 int overwrite_console (void)
@@ -120,7 +120,7 @@ static void usb_kbd_put_queue(char data)
 /* test if a character is in the queue */
 static int usb_kbd_testc(void)
 {
-#ifdef CFG_USB_EVENT_POLL
+#ifdef CONFIG_SYS_USB_EVENT_POLL
        usb_event_poll();
 #endif
        if(usb_in_pointer==usb_out_pointer)
@@ -133,7 +133,7 @@ static int usb_kbd_getc(void)
 {
        char c;
        while(usb_in_pointer==usb_out_pointer) {
-#ifdef CFG_USB_EVENT_POLL
+#ifdef CONFIG_SYS_USB_EVENT_POLL
                usb_event_poll();
 #endif
        }
@@ -153,7 +153,7 @@ static int usb_kbd_probe(struct usb_device *dev, unsigned int ifnum);
 int drv_usb_kbd_init(void)
 {
        int error,i;
-       device_t usb_kbd_dev,*old_dev;
+       struct stdio_dev usb_kbd_dev,*old_dev;
        struct usb_device *dev;
        char *stdinname  = getenv ("stdin");
 
@@ -162,11 +162,13 @@ int drv_usb_kbd_init(void)
        /* scan all USB Devices */
        for(i=0;i<USB_MAX_DEVICE;i++) {
                dev=usb_get_dev_index(i); /* get device */
+               if(dev == NULL)
+                       return -1;
                if(dev->devnum!=-1) {
                        if(usb_kbd_probe(dev,0)==1) { /* Ok, we found a keyboard */
                                /* check, if it is already registered */
                                USB_KBD_PRINTF("USB KBD found set up device.\n");
-                               old_dev = device_get_by_name(DEVNAME);
+                               old_dev = stdio_get_by_name(DEVNAME);
                                if(old_dev) {
                                        /* ok, already registered, just return ok */
                                        USB_KBD_PRINTF("USB KBD is already registered.\n");
@@ -174,14 +176,15 @@ int drv_usb_kbd_init(void)
                                }
                                /* register the keyboard */
                                USB_KBD_PRINTF("USB KBD register.\n");
-                               memset (&usb_kbd_dev, 0, sizeof(device_t));
+                               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;
-                               error = device_register (&usb_kbd_dev);
+                               usb_kbd_dev.priv = (void *)dev;
+                               error = stdio_register (&usb_kbd_dev);
                                if(error==0) {
                                        /* check if this is the standard input device */
                                        if(strcmp(stdinname,DEVNAME)==0) {
@@ -209,7 +212,11 @@ int drv_usb_kbd_init(void)
 /* deregistering the keyboard */
 int usb_kbd_deregister(void)
 {
-       return device_deregister(DEVNAME);
+#ifdef CONFIG_SYS_STDIO_DEREGISTER
+       return stdio_deregister(DEVNAME);
+#else
+       return 1;
+#endif
 }
 
 /**************************************************************************