]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/class.c
Driver core: change sysdev classes to use dynamic kobject names
[linux-2.6-omap-h63xx.git] / drivers / base / class.c
index 3ffcda753e7804705e4096e13843ccb162224be1..b962a76875d276349ffc9130734387e52a673126 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kdev_t.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/genhd.h>
 #include "base.h"
 
 #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
@@ -149,7 +150,13 @@ int class_register(struct class * cls)
        if (error)
                return error;
 
+#ifdef CONFIG_SYSFS_DEPRECATED
+       /* let the block class directory show up in the root of sysfs */
+       if (cls != &block_class)
+               cls->subsys.kobj.kset = class_kset;
+#else
        cls->subsys.kobj.kset = class_kset;
+#endif
        cls->subsys.kobj.ktype = &class_ktype;
 
        error = kset_register(&cls->subsys);
@@ -459,7 +466,6 @@ static struct kset_uevent_ops class_uevent_ops = {
  * entirely soon.
  */
 static struct kset class_obj_subsys = {
-       .kobj = { .k_name = "class_obj", },
        .uevent_ops = &class_uevent_ops,
 };
 
@@ -546,8 +552,7 @@ static struct class_device_attribute class_uevent_attr =
 void class_device_initialize(struct class_device *class_dev)
 {
        class_dev->kobj.kset = &class_obj_subsys;
-       class_dev->kobj.ktype = &class_device_ktype;
-       kobject_init(&class_dev->kobj);
+       kobject_init(&class_dev->kobj, &class_device_ktype);
        INIT_LIST_HEAD(&class_dev->node);
 }
 
@@ -575,16 +580,13 @@ int class_device_add(struct class_device *class_dev)
                 class_dev->class_id);
 
        /* first, register with generic layer. */
-       error = kobject_set_name(&class_dev->kobj, "%s", class_dev->class_id);
-       if (error)
-               goto out2;
-
        if (parent_class_dev)
                class_dev->kobj.parent = &parent_class_dev->kobj;
        else
                class_dev->kobj.parent = &parent_class->subsys.kobj;
 
-       error = kobject_add(&class_dev->kobj);
+       error = kobject_add(&class_dev->kobj, class_dev->kobj.parent,
+                           "%s", class_dev->class_id);
        if (error)
                goto out2;
 
@@ -869,6 +871,7 @@ int __init classes_init(void)
        /* ick, this is ugly, the things we go through to keep from showing up
         * in sysfs... */
        kset_init(&class_obj_subsys);
+       kobject_set_name(&class_obj_subsys.kobj, "class_obj");
        if (!class_obj_subsys.kobj.parent)
                class_obj_subsys.kobj.parent = &class_obj_subsys.kobj;
        return 0;