Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4967f2e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by TARKZiM
Browse files

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: default avatarGuenter Roeck <linux@roeck-us.net>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: Ic234648e9e6a501f8e4e9eaf2e7d56bf0fa8496f
parent 821138c7
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -498,9 +498,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;
@@ -527,6 +530,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;
}
@@ -544,6 +550,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);
	}
}

+3 −1
Original line number Diff line number Diff line
@@ -315,6 +315,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.
@@ -344,7 +345,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;