X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fstdio.c;h=8311ac768c90d0b0fc0b072215cfa5bd36070e2f;hb=434afa809e91bbf67e003df8daf0e2f39c48ce59;hp=68c595d2d79c292e3ac9b93ae55b0b22bf0e27f0;hpb=5aa7bece1045c28806ce919099616ebe8fa63325;p=u-boot diff --git a/common/stdio.c b/common/stdio.c index 68c595d2d7..8311ac768c 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -24,6 +25,8 @@ #include #endif +#include + DECLARE_GLOBAL_DATA_PTR; static struct stdio_dev devs; @@ -88,7 +91,7 @@ static void drv_system_init (void) memset (&dev, 0, sizeof (dev)); strcpy (dev.name, "serial"); - dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; + dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; dev.putc = stdio_serial_putc; dev.puts = stdio_serial_puts; dev.getc = stdio_serial_getc; @@ -99,7 +102,7 @@ static void drv_system_init (void) memset (&dev, 0, sizeof (dev)); strcpy (dev.name, "nulldev"); - dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM; + dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT; dev.putc = nulldev_putc; dev.puts = nulldev_puts; dev.getc = nulldev_input; @@ -197,6 +200,7 @@ int stdio_deregister_dev(struct stdio_dev *dev, int force) } list_del(&(dev->list)); + free(dev); /* reassign Device list */ list_for_each(pos, &(devs.list)) { @@ -244,6 +248,32 @@ int stdio_init_tables(void) int stdio_add_devices(void) { +#ifdef CONFIG_DM_KEYBOARD + struct udevice *dev; + struct uclass *uc; + int ret; + + /* + * For now we probe all the devices here. At some point this should be + * done only when the devices are required - e.g. we have a list of + * input devices to start up in the stdin environment variable. That + * work probably makes more sense when stdio itself is converted to + * driver model. + * + * TODO(sjg@chromium.org): Convert changing uclass_first_device() etc. + * to return the device even on error. Then we could use that here. + */ + ret = uclass_get(UCLASS_KEYBOARD, &uc); + if (ret) + return ret; + + /* Don't report errors to the caller - assume that they are non-fatal */ + uclass_foreach_dev(dev, uc) { + ret = device_probe(dev); + if (ret) + printf("Failed to probe keyboard '%s'\n", dev->name); + } +#endif #ifdef CONFIG_SYS_I2C i2c_init_all(); #else @@ -257,7 +287,7 @@ int stdio_add_devices(void) #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) drv_video_init (); #endif -#ifdef CONFIG_KEYBOARD +#if defined(CONFIG_KEYBOARD) && !defined(CONFIG_DM_KEYBOARD) drv_keyboard_init (); #endif #ifdef CONFIG_LOGBUFFER