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

Commit bd735995 authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman
Browse files

misc: Add attribute groups



Add groups field to struct miscdevice for passing the attribute groups
at device creation.  In this way, the driver can avoid the manual call
of device_create_file() after the device registration, which is
basically a racy operation, in addition to the reduction of manual
device_remove_file() calls.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2f976319
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -207,8 +207,9 @@ int misc_register(struct miscdevice * misc)

	dev = MKDEV(MISC_MAJOR, misc->minor);

	misc->this_device = device_create(misc_class, misc->parent, dev,
					  misc, "%s", misc->name);
	misc->this_device =
		device_create_with_groups(misc_class, misc->parent, dev,
					  misc, misc->groups, "%s", misc->name);
	if (IS_ERR(misc->this_device)) {
		int i = DYNAMIC_MINORS - misc->minor - 1;
		if (i < DYNAMIC_MINORS && i >= 0)
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#define MISC_DYNAMIC_MINOR	255

struct device;
struct attribute_group;

struct miscdevice  {
	int minor;
@@ -60,6 +61,7 @@ struct miscdevice {
	struct list_head list;
	struct device *parent;
	struct device *this_device;
	const struct attribute_group **groups;
	const char *nodename;
	umode_t mode;
};