misc: Add attribute groups
authorTakashi Iwai <tiwai@suse.de>
Mon, 2 Feb 2015 14:44:54 +0000 (15:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2015 10:44:52 +0000 (11:44 +0100)
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: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/misc.c
include/linux/miscdevice.h

index c892c296a4dea06c07cc7ecfc206e87ba4baab56..5bb3a2109ab729c260767455c17016876a2f5e1d 100644 (file)
@@ -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)
index ee80dd7d9f60fb6e289f798d37b8725d55a71d02..819077c326901384ec3bdb8d16217a1363ab8e28 100644 (file)
@@ -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;
 };
This page took 0.027554 seconds and 5 git commands to generate.