]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
driver core: get rid of struct device's bus_id string array
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 25 Jan 2009 14:17:37 +0000 (15:17 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 24 Mar 2009 23:38:23 +0000 (16:38 -0700)
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>
drivers/base/core.c
include/linux/device.h
include/linux/kobject.h
lib/kobject.c

index f3eae630e5899707e485396b3d427255ef9964d1..059966b617f67c3248153f53ae6b932d887105c9 100644 (file)
@@ -777,17 +777,12 @@ static void device_remove_class_symlinks(struct device *dev)
 int dev_set_name(struct device *dev, const char *fmt, ...)
 {
        va_list vargs;
-       char *s;
+       int err;
 
        va_start(vargs, fmt);
-       vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
+       err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
        va_end(vargs);
-
-       /* ewww... some of these buggers have / in the name... */
-       while ((s = strchr(dev->bus_id, '/')))
-               *s = '!';
-
-       return 0;
+       return err;
 }
 EXPORT_SYMBOL_GPL(dev_set_name);
 
@@ -864,12 +859,17 @@ int device_add(struct device *dev)
        if (!dev)
                goto done;
 
-       /* Temporarily support init_name if it is set.
-        * It will override bus_id for now */
-       if (dev->init_name)
-               dev_set_name(dev, "%s", dev->init_name);
+       /*
+        * for statically allocated devices, which should all be converted
+        * some day, we need to initialize the name. We prevent reading back
+        * the name, and force the use of dev_name()
+        */
+       if (dev->init_name) {
+               dev_set_name(dev, dev->init_name);
+               dev->init_name = NULL;
+       }
 
-       if (!strlen(dev->bus_id))
+       if (!dev_name(dev))
                goto done;
 
        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,
        dev->release = device_create_release;
        dev_set_drvdata(dev, drvdata);
 
-       vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args);
+       retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
+       if (retval)
+               goto error;
+
        retval = device_register(dev);
        if (retval)
                goto error;
@@ -1452,19 +1455,15 @@ int device_rename(struct device *dev, char *new_name)
                old_class_name = make_class_name(dev->class->name, &dev->kobj);
 #endif
 
-       old_device_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
+       old_device_name = kstrdup(dev_name(dev), GFP_KERNEL);
        if (!old_device_name) {
                error = -ENOMEM;
                goto out;
        }
-       strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE);
-       strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);
 
        error = kobject_rename(&dev->kobj, new_name);
-       if (error) {
-               strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE);
+       if (error)
                goto out;
-       }
 
 #ifdef CONFIG_SYSFS_DEPRECATED
        if (old_class_name) {
index 47f343c7bddaaca551c8fb2114160fb5f362c4e1..d5706c448bcb7c45b0f83f2ea46bfddc28673d5b 100644 (file)
@@ -374,7 +374,6 @@ struct device {
        struct device           *parent;
 
        struct kobject kobj;
-       char    bus_id[BUS_ID_SIZE];    /* position on parent bus */
        unsigned                uevent_suppress:1;
        const char              *init_name; /* initial name of the device */
        struct device_type      *type;
@@ -427,8 +426,7 @@ struct device {
 
 static inline const char *dev_name(const struct device *dev)
 {
-       /* will be changed into kobject_name(&dev->kobj) in the near future */
-       return dev->bus_id;
+       return kobject_name(&dev->kobj);
 }
 
 extern int dev_set_name(struct device *dev, const char *name, ...)
index 5437ac0276e232d259a886e7b644f4b4e2e44935..c9c214d7bba2540fa0e83fb635396287c79a7310 100644 (file)
@@ -72,6 +72,8 @@ struct kobject {
 
 extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
                            __attribute__((format(printf, 2, 3)));
+extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
+                                 va_list vargs);
 
 static inline const char *kobject_name(const struct kobject *kobj)
 {
index 0487d1f64806c645927fdc22ea4a5848f3d9ea5f..a6dec32f2ddd5f683c5d1295358dc11842ebd2e7 100644 (file)
@@ -212,7 +212,7 @@ static int kobject_add_internal(struct kobject *kobj)
  * @fmt: format string used to build the name
  * @vargs: vargs to format the string.
  */
-static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
+int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
                                  va_list vargs)
 {
        const char *old_name = kobj->name;