sysfs: add /sys/dev/{char,block} to lookup sysfs path by major:minor
[firefly-linux-kernel-4.4.55.git] / drivers / base / class.c
index 0ef00e8d4153879513bfa2823a7fad0e25e4f6b7..71ce3ff6bdf53261af4cc41e5763846803569f27 100644 (file)
@@ -140,7 +140,6 @@ int class_register(struct class *cls)
 
        pr_debug("device class '%s': registering\n", cls->name);
 
-       INIT_LIST_HEAD(&cls->children);
        INIT_LIST_HEAD(&cls->devices);
        INIT_LIST_HEAD(&cls->interfaces);
        kset_init(&cls->class_dirs);
@@ -149,6 +148,10 @@ int class_register(struct class *cls)
        if (error)
                return error;
 
+       /* set the default /sys/dev directory for devices of this class */
+       if (!cls->dev_kobj)
+               cls->dev_kobj = sysfs_dev_char_kobj;
+
 #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
        /* let the block class directory show up in the root of sysfs */
        if (cls != &block_class)