[PATCH] Driver core: change make_class_name() to take kobjects
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 20 Jun 2006 20:59:20 +0000 (13:59 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Jun 2006 19:40:49 +0000 (12:40 -0700)
This is needed for a future patch for the device code to create the
proper symlinks for devices that are "class devices".

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/base.h
drivers/base/class.c

index 79115eff6e9485892182c2380159f82e41dd13e9..c3b8dc98b8a739812f78b5311b38bf18d671a8c7 100644 (file)
@@ -42,4 +42,5 @@ struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
        return container_of(_attr, struct class_device_attribute, attr);
 }
 
+extern char *make_class_name(const char *name, struct kobject *kobj);
 
index 4b598be0e4b6c8938255824f2432b72d3bd4ce43..41a8e0934e3a70c299b747c7187499238689a65a 100644 (file)
@@ -504,22 +504,21 @@ void class_device_initialize(struct class_device *class_dev)
        INIT_LIST_HEAD(&class_dev->node);
 }
 
-static char *make_class_name(struct class_device *class_dev)
+char *make_class_name(const char *name, struct kobject *kobj)
 {
-       char *name;
+       char *class_name;
        int size;
 
-       size = strlen(class_dev->class->name) +
-               strlen(kobject_name(&class_dev->kobj)) + 2;
+       size = strlen(name) + strlen(kobject_name(kobj)) + 2;
 
-       name = kmalloc(size, GFP_KERNEL);
-       if (!name)
+       class_name = kmalloc(size, GFP_KERNEL);
+       if (!class_name)
                return ERR_PTR(-ENOMEM);
 
-       strcpy(name, class_dev->class->name);
-       strcat(name, ":");
-       strcat(name, kobject_name(&class_dev->kobj));
-       return name;
+       strcpy(class_name, name);
+       strcat(class_name, ":");
+       strcat(class_name, kobject_name(kobj));
+       return class_name;
 }
 
 int class_device_add(struct class_device *class_dev)
@@ -594,7 +593,8 @@ int class_device_add(struct class_device *class_dev)
                goto out5;
 
        if (class_dev->dev) {
-               class_name = make_class_name(class_dev);
+               class_name = make_class_name(class_dev->class->name,
+                                            &class_dev->kobj);
                error = sysfs_create_link(&class_dev->kobj,
                                          &class_dev->dev->kobj, "device");
                if (error)
@@ -731,7 +731,8 @@ void class_device_del(struct class_device *class_dev)
        }
 
        if (class_dev->dev) {
-               class_name = make_class_name(class_dev);
+               class_name = make_class_name(class_dev->class->name,
+                                            &class_dev->kobj);
                sysfs_remove_link(&class_dev->kobj, "device");
                sysfs_remove_link(&class_dev->dev->kobj, class_name);
        }
@@ -796,14 +797,16 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
                 new_name);
 
        if (class_dev->dev)
-               old_class_name = make_class_name(class_dev);
+               old_class_name = make_class_name(class_dev->class->name,
+                                                &class_dev->kobj);
 
        strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN);
 
        error = kobject_rename(&class_dev->kobj, new_name);
 
        if (class_dev->dev) {
-               new_class_name = make_class_name(class_dev);
+               new_class_name = make_class_name(class_dev->class->name,
+                                                &class_dev->kobj);
                sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
                                  new_class_name);
                sysfs_remove_link(&class_dev->dev->kobj, old_class_name);