diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-01-25 09:17:37 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:23 -0400 |
commit | 1fa5ae857bb14f6046205171d98506d8112dd74e (patch) | |
tree | 218821345d2c9394bd6184bdb0cd0cb2f1f30d4c | |
parent | 6866ac9db02ac1ec71f2aa720a1019581f69a725 (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>
-rw-r--r-- | drivers/base/core.c | 39 | ||||
-rw-r--r-- | include/linux/device.h | 4 | ||||
-rw-r--r-- | include/linux/kobject.h | 2 | ||||
-rw-r--r-- | lib/kobject.c | 2 |
4 files changed, 23 insertions, 24 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) | |||
777 | int dev_set_name(struct device *dev, const char *fmt, ...) | 777 | int 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 | } |
792 | EXPORT_SYMBOL_GPL(dev_set_name); | 787 | EXPORT_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) { |
diff --git a/include/linux/device.h b/include/linux/device.h index 47f343c7bdda..d5706c448bcb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -374,7 +374,6 @@ struct device { | |||
374 | struct device *parent; | 374 | struct device *parent; |
375 | 375 | ||
376 | struct kobject kobj; | 376 | struct kobject kobj; |
377 | char bus_id[BUS_ID_SIZE]; /* position on parent bus */ | ||
378 | unsigned uevent_suppress:1; | 377 | unsigned uevent_suppress:1; |
379 | const char *init_name; /* initial name of the device */ | 378 | const char *init_name; /* initial name of the device */ |
380 | struct device_type *type; | 379 | struct device_type *type; |
@@ -427,8 +426,7 @@ struct device { | |||
427 | 426 | ||
428 | static inline const char *dev_name(const struct device *dev) | 427 | static inline const char *dev_name(const struct device *dev) |
429 | { | 428 | { |
430 | /* will be changed into kobject_name(&dev->kobj) in the near future */ | 429 | return kobject_name(&dev->kobj); |
431 | return dev->bus_id; | ||
432 | } | 430 | } |
433 | 431 | ||
434 | extern int dev_set_name(struct device *dev, const char *name, ...) | 432 | extern int dev_set_name(struct device *dev, const char *name, ...) |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 5437ac0276e2..c9c214d7bba2 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -72,6 +72,8 @@ struct kobject { | |||
72 | 72 | ||
73 | extern int kobject_set_name(struct kobject *kobj, const char *name, ...) | 73 | extern int kobject_set_name(struct kobject *kobj, const char *name, ...) |
74 | __attribute__((format(printf, 2, 3))); | 74 | __attribute__((format(printf, 2, 3))); |
75 | extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, | ||
76 | va_list vargs); | ||
75 | 77 | ||
76 | static inline const char *kobject_name(const struct kobject *kobj) | 78 | static inline const char *kobject_name(const struct kobject *kobj) |
77 | { | 79 | { |
diff --git a/lib/kobject.c b/lib/kobject.c index 0487d1f64806..a6dec32f2ddd 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -212,7 +212,7 @@ static int kobject_add_internal(struct kobject *kobj) | |||
212 | * @fmt: format string used to build the name | 212 | * @fmt: format string used to build the name |
213 | * @vargs: vargs to format the string. | 213 | * @vargs: vargs to format the string. |
214 | */ | 214 | */ |
215 | static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, | 215 | int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, |
216 | va_list vargs) | 216 | va_list vargs) |
217 | { | 217 | { |
218 | const char *old_name = kobj->name; | 218 | const char *old_name = kobj->name; |