]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
driver core: add default groups to struct class
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 14 Jul 2013 23:05:58 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Jul 2013 17:57:37 +0000 (10:57 -0700)
We should be using groups, not attribute lists, for classes to allow
subdirectories, and soon, binary files.  Groups are just more flexible
overall, so add them.

The dev_attrs list will go away after all in-kernel users are converted
to use dev_groups.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c
include/linux/device.h

index a8aae1823f73115375e02d5dd8519b01bebed862..8856d74545d988271986f9152380ba3f615f9f8a 100644 (file)
@@ -528,9 +528,12 @@ static int device_add_attrs(struct device *dev)
        int error;
 
        if (class) {
-               error = device_add_attributes(dev, class->dev_attrs);
+               error = device_add_groups(dev, class->dev_groups);
                if (error)
                        return error;
+               error = device_add_attributes(dev, class->dev_attrs);
+               if (error)
+                       goto err_remove_class_groups;
                error = device_add_bin_attributes(dev, class->dev_bin_attrs);
                if (error)
                        goto err_remove_class_attrs;
@@ -563,6 +566,9 @@ static int device_add_attrs(struct device *dev)
  err_remove_class_attrs:
        if (class)
                device_remove_attributes(dev, class->dev_attrs);
+ err_remove_class_groups:
+       if (class)
+               device_remove_groups(dev, class->dev_groups);
 
        return error;
 }
@@ -581,6 +587,7 @@ static void device_remove_attrs(struct device *dev)
        if (class) {
                device_remove_attributes(dev, class->dev_attrs);
                device_remove_bin_attributes(dev, class->dev_bin_attrs);
+               device_remove_groups(dev, class->dev_groups);
        }
 }
 
index bd5931e89f7483728d1c0436a468a0796065a485..22b546a585916b2c8b5754c3f321130c7231d1fe 100644 (file)
@@ -320,6 +320,7 @@ int subsys_virtual_register(struct bus_type *subsys,
  * @name:      Name of the class.
  * @owner:     The module owner.
  * @class_attrs: Default attributes of this class.
+ * @dev_groups:        Default attributes of the devices that belong to the class.
  * @dev_attrs: Default attributes of the devices belong to the class.
  * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
  * @dev_kobj:  The kobject that represents this class and links it into the hierarchy.
@@ -349,7 +350,8 @@ struct class {
        struct module           *owner;
 
        struct class_attribute          *class_attrs;
-       struct device_attribute         *dev_attrs;
+       struct device_attribute         *dev_attrs;     /* use dev_groups instead */
+       const struct attribute_group    **dev_groups;
        struct bin_attribute            *dev_bin_attrs;
        struct kobject                  *dev_kobj;