to prevent that the pointer will not be use for an other register Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <[EMAIL PROTECTED]> --- common/devices.c | 24 +++++++++++++++++++++++- include/devices.h | 1 + 2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/common/devices.c b/common/devices.c index 2977436..8beebe2 100644 --- a/common/devices.c +++ b/common/devices.c @@ -130,10 +130,32 @@ device_t* device_get_by_name(char* name) return NULL; } +device_t* device_clone(device_t *dev) +{ + device_t *_dev; + + if(!dev) + return NULL; + + _dev = calloc(1, sizeof(device_t)); + + if(!_dev) + return NULL; + + memcpy(_dev, dev, sizeof(device_t)); + strncpy(_dev->name, dev->name, 16); + + return _dev; +} int device_register (device_t * dev) { - list_add(&(dev->list), &(devs.list)); + device_t *_dev; + + _dev = device_clone(dev); + if(!_dev) + return -1; + list_add(&(_dev->list), &(devs.list)); return 0; } diff --git a/include/devices.h b/include/devices.h index 490016b..6b78d58 100644 --- a/include/devices.h +++ b/include/devices.h @@ -94,6 +94,7 @@ int devices_init (void); int device_deregister(char *devname); struct list_head* device_get_list(void); device_t* device_get_by_name(char* name); +device_t* device_clone(device_t *dev); #ifdef CONFIG_LCD int drv_lcd_init (void); -- 1.5.6.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot