aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-14 19:05:58 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-16 13:57:37 -0400
commitd05a6f96c76062b5f25858ac02cf677602076f7e (patch)
tree4c159b303e3e88c0a5e490f03619f2f7f7a2a859
parent39ef311204941ddd01ea2950d6220c8ccc710d15 (diff)
driver core: add default groups to struct class
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>
-rw-r--r--drivers/base/core.c9
-rw-r--r--include/linux/device.h4
2 files changed, 11 insertions, 2 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a8aae1823f73..8856d74545d9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -528,9 +528,12 @@ static int device_add_attrs(struct device *dev)
528 int error; 528 int error;
529 529
530 if (class) { 530 if (class) {
531 error = device_add_attributes(dev, class->dev_attrs); 531 error = device_add_groups(dev, class->dev_groups);
532 if (error) 532 if (error)
533 return error; 533 return error;
534 error = device_add_attributes(dev, class->dev_attrs);
535 if (error)
536 goto err_remove_class_groups;
534 error = device_add_bin_attributes(dev, class->dev_bin_attrs); 537 error = device_add_bin_attributes(dev, class->dev_bin_attrs);
535 if (error) 538 if (error)
536 goto err_remove_class_attrs; 539 goto err_remove_class_attrs;
@@ -563,6 +566,9 @@ static int device_add_attrs(struct device *dev)
563 err_remove_class_attrs: 566 err_remove_class_attrs:
564 if (class) 567 if (class)
565 device_remove_attributes(dev, class->dev_attrs); 568 device_remove_attributes(dev, class->dev_attrs);
569 err_remove_class_groups:
570 if (class)
571 device_remove_groups(dev, class->dev_groups);
566 572
567 return error; 573 return error;
568} 574}
@@ -581,6 +587,7 @@ static void device_remove_attrs(struct device *dev)
581 if (class) { 587 if (class) {
582 device_remove_attributes(dev, class->dev_attrs); 588 device_remove_attributes(dev, class->dev_attrs);
583 device_remove_bin_attributes(dev, class->dev_bin_attrs); 589 device_remove_bin_attributes(dev, class->dev_bin_attrs);
590 device_remove_groups(dev, class->dev_groups);
584 } 591 }
585} 592}
586 593
diff --git a/include/linux/device.h b/include/linux/device.h
index bd5931e89f74..22b546a58591 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -320,6 +320,7 @@ int subsys_virtual_register(struct bus_type *subsys,
320 * @name: Name of the class. 320 * @name: Name of the class.
321 * @owner: The module owner. 321 * @owner: The module owner.
322 * @class_attrs: Default attributes of this class. 322 * @class_attrs: Default attributes of this class.
323 * @dev_groups: Default attributes of the devices that belong to the class.
323 * @dev_attrs: Default attributes of the devices belong to the class. 324 * @dev_attrs: Default attributes of the devices belong to the class.
324 * @dev_bin_attrs: Default binary attributes of the devices belong to the class. 325 * @dev_bin_attrs: Default binary attributes of the devices belong to the class.
325 * @dev_kobj: The kobject that represents this class and links it into the hierarchy. 326 * @dev_kobj: The kobject that represents this class and links it into the hierarchy.
@@ -349,7 +350,8 @@ struct class {
349 struct module *owner; 350 struct module *owner;
350 351
351 struct class_attribute *class_attrs; 352 struct class_attribute *class_attrs;
352 struct device_attribute *dev_attrs; 353 struct device_attribute *dev_attrs; /* use dev_groups instead */
354 const struct attribute_group **dev_groups;
353 struct bin_attribute *dev_bin_attrs; 355 struct bin_attribute *dev_bin_attrs;
354 struct kobject *dev_kobj; 356 struct kobject *dev_kobj;
355 357