aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-01-25 09:17:37 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:38:23 -0400
commit1fa5ae857bb14f6046205171d98506d8112dd74e (patch)
tree218821345d2c9394bd6184bdb0cd0cb2f1f30d4c /drivers
parent6866ac9db02ac1ec71f2aa720a1019581f69a725 (diff)
driver core: get rid of struct device's bus_id string array
Now that all users of bus_id is gone, we can remove it from struct device. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/core.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index f3eae630e589..059966b617f6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -777,17 +777,12 @@ static void device_remove_class_symlinks(struct device *dev)
777int dev_set_name(struct device *dev, const char *fmt, ...) 777int dev_set_name(struct device *dev, const char *fmt, ...)
778{ 778{
779 va_list vargs; 779 va_list vargs;
780 char *s; 780 int err;
781 781
782 va_start(vargs, fmt); 782 va_start(vargs, fmt);
783 vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs); 783 err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
784 va_end(vargs); 784 va_end(vargs);
785 785 return err;
786 /* ewww... some of these buggers have / in the name... */
787 while ((s = strchr(dev->bus_id, '/')))
788 *s = '!';
789
790 return 0;
791} 786}
792EXPORT_SYMBOL_GPL(dev_set_name); 787EXPORT_SYMBOL_GPL(dev_set_name);
793 788
@@ -864,12 +859,17 @@ int device_add(struct device *dev)
864 if (!dev) 859 if (!dev)
865 goto done; 860 goto done;
866 861
867 /* Temporarily support init_name if it is set. 862 /*
868 * It will override bus_id for now */ 863 * for statically allocated devices, which should all be converted
869 if (dev->init_name) 864 * some day, we need to initialize the name. We prevent reading back
870 dev_set_name(dev, "%s", dev->init_name); 865 * the name, and force the use of dev_name()
866 */
867 if (dev->init_name) {
868 dev_set_name(dev, dev->init_name);
869 dev->init_name = NULL;
870 }
871 871
872 if (!strlen(dev->bus_id)) 872 if (!dev_name(dev))
873 goto done; 873 goto done;
874 874
875 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); 875 pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
@@ -1348,7 +1348,10 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
1348 dev->release = device_create_release; 1348 dev->release = device_create_release;
1349 dev_set_drvdata(dev, drvdata); 1349 dev_set_drvdata(dev, drvdata);
1350 1350
1351 vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); 1351 retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
1352 if (retval)
1353 goto error;
1354
1352 retval = device_register(dev); 1355 retval = device_register(dev);
1353 if (retval) 1356 if (retval)
1354 goto error; 1357 goto error;
@@ -1452,19 +1455,15 @@ int device_rename(struct device *dev, char *new_name)
1452 old_class_name = make_class_name(dev->class->name, &dev->kobj); 1455 old_class_name = make_class_name(dev->class->name, &dev->kobj);
1453#endif 1456#endif
1454 1457
1455 old_device_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 1458 old_device_name = kstrdup(dev_name(dev), GFP_KERNEL);
1456 if (!old_device_name) { 1459 if (!old_device_name) {
1457 error = -ENOMEM; 1460 error = -ENOMEM;
1458 goto out; 1461 goto out;
1459 } 1462 }
1460 strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE);
1461 strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);
1462 1463
1463 error = kobject_rename(&dev->kobj, new_name); 1464 error = kobject_rename(&dev->kobj, new_name);
1464 if (error) { 1465 if (error)
1465 strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE);
1466 goto out; 1466 goto out;
1467 }
1468 1467
1469#ifdef CONFIG_SYSFS_DEPRECATED 1468#ifdef CONFIG_SYSFS_DEPRECATED
1470 if (old_class_name) { 1469 if (old_class_name) {