diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2010-08-30 00:17:52 +0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-09-20 08:56:37 +0200 |
commit | c33a2e503c32696bbf5f2388599cabc5d4d45c01 (patch) | |
tree | 7bdb091040a852377b0b4671c0655137119fad1e /lib | |
parent | e34c1d4fccda53fe7f83dba57d1102e4ba2baf91 (diff) | |
download | barebox-c33a2e503c32696bbf5f2388599cabc5d4d45c01.tar.gz barebox-c33a2e503c32696bbf5f2388599cabc5d4d45c01.tar.xz |
device: fix dev_name
dev_name is supposed to return the name of the device plus the id
currently we use %s%d format where in the kernel the use %s.%d
we may think to switch to this format for the device name and keeping the %s%d
for the devfs
this will be usefull to not modify the clock device name as example
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/driver.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/driver.c b/lib/driver.c index 00aca9cf71..39881c2391 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -45,11 +45,9 @@ static LIST_HEAD(active); struct device_d *get_device_by_name(const char *name) { struct device_d *dev; - char devname[MAX_DRIVER_NAME + 3]; for_each_device(dev) { - sprintf(devname, "%s%d", dev->name, dev->id); - if(!strcmp(name, devname)) + if(!strcmp(dev_name(dev), name)) return dev; } @@ -115,7 +113,7 @@ int register_device(struct device_d *new_device) } } - debug ("register_device: %s\n",new_device->name); + debug ("register_device: %s\n", dev_name(new_device)); if (!new_device->bus) { // dev_err(new_device, "no bus type associated. Needs fixup\n"); @@ -138,7 +136,7 @@ EXPORT_SYMBOL(register_device); int unregister_device(struct device_d *old_dev) { - debug("unregister_device: %s:%s\n",old_dev->name, old_dev->id); + debug("unregister_device: %s\n", dev_name(old_dev)); if (!list_empty(&old_dev->children)) { errno = -EBUSY; @@ -182,7 +180,7 @@ struct driver_d *get_driver_by_name(const char *name) static void noinfo(struct device_d *dev) { - printf("no info available for %s\n", dev->name); + printf("no info available for %s\n", dev_name(dev)); } static void noshortinfo(struct device_d *dev) @@ -255,7 +253,7 @@ static int do_devinfo_subtree(struct device_d *dev, int depth, char edge) for (i = 0; i < depth; i++) printf("| "); - printf("%c----%s%d", edge, dev->name, dev->id); + printf("%c----%s", edge, dev_name(dev)); if (!list_empty(&dev->cdevs)) { printf(" ("); list_for_each_entry(cdev, &dev->cdevs, devices_list) { @@ -282,7 +280,7 @@ const char *dev_id(const struct device_d *dev) { static char buf[sizeof(unsigned long) * 2]; - sprintf(buf, "%s%d", dev->name, dev->id); + sprintf(buf, FORMAT_DRIVER_MANE_ID, dev->name, dev->id); return buf; } |