X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fstdio.c;h=c878103a4826b6d9f72b669125523a9b613d6bb3;hb=1e3d64031608d668509b6fe0825f7708bb6b6a0d;hp=dd402cc23d51b6ff336ee5435a3ed1e612dec080;hpb=709ea543b92489e7729d2d7ddd6c9f451e52158c;p=u-boot diff --git a/common/stdio.c b/common/stdio.c index dd402cc23d..c878103a48 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -148,32 +149,35 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev) return _dev; } -int stdio_register (struct stdio_dev * dev) +int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp) { struct stdio_dev *_dev; _dev = stdio_clone(dev); if(!_dev) - return -1; + return -ENODEV; list_add_tail(&(_dev->list), &(devs.list)); + if (devp) + *devp = _dev; + return 0; } +int stdio_register(struct stdio_dev *dev) +{ + return stdio_register_dev(dev, NULL); +} + /* deregister the device "devname". * returns 0 if success, -1 if device is assigned and 1 if devname not found */ #ifdef CONFIG_SYS_STDIO_DEREGISTER -int stdio_deregister(const char *devname) +int stdio_deregister_dev(struct stdio_dev *dev) { int l; struct list_head *pos; - struct stdio_dev *dev; char temp_names[3][16]; - dev = stdio_get_by_name(devname); - - if(!dev) /* device not found */ - return -1; /* get stdio devices (ListRemoveItem changes the dev list) */ for (l=0 ; l< MAX_FILES; l++) { if (stdio_devices[l] == dev) { @@ -197,9 +201,21 @@ int stdio_deregister(const char *devname) } return 0; } + +int stdio_deregister(const char *devname) +{ + struct stdio_dev *dev; + + dev = stdio_get_by_name(devname); + + if (!dev) /* device not found */ + return -ENODEV; + + return stdio_deregister_dev(dev); +} #endif /* CONFIG_SYS_STDIO_DEREGISTER */ -int stdio_init (void) +int stdio_init_tables(void) { #if defined(CONFIG_NEEDS_MANUAL_RELOC) /* already relocated for current ARM implementation */ @@ -216,6 +232,11 @@ int stdio_init (void) /* Initialize the list */ INIT_LIST_HEAD(&(devs.list)); + return 0; +} + +int stdio_add_devices(void) +{ #ifdef CONFIG_SYS_I2C i2c_init_all(); #else @@ -249,5 +270,14 @@ int stdio_init (void) #ifdef CONFIG_CBMEM_CONSOLE cbmemc_init(); #endif - return (0); + + return 0; +} + +int stdio_init(void) +{ + stdio_init_tables(); + stdio_add_devices(); + + return 0; }