diff options
| author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2008-09-01 17:11:26 +0200 | 
|---|---|---|
| committer | Wolfgang Denk <wd@denx.de> | 2008-09-02 01:28:18 +0200 | 
| commit | 628ffd73bcff0c9f3bc5a8eeb2c7455fe9d28a51 (patch) | |
| tree | b7fed06affccfa97aae1344c6f4f5026440513fb /common/devices.c | |
| parent | e99e9575bbeba1b7c48e046547cae065ec0071de (diff) | |
| download | olio-uboot-2014.01-628ffd73bcff0c9f3bc5a8eeb2c7455fe9d28a51.tar.xz olio-uboot-2014.01-628ffd73bcff0c9f3bc5a8eeb2c7455fe9d28a51.zip | |
device: make device_register() clone the device
This is expected by the callers, but this fact was hidden well within
the old list implementation.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'common/devices.c')
| -rw-r--r-- | common/devices.c | 24 | 
1 files changed, 23 insertions, 1 deletions
| diff --git a/common/devices.c b/common/devices.c index 297743642..8beebe255 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;  } |