sysfs.h: add ATTRIBUTE_GROUPS() macro
Quoted 14 lines · Greg Kroah-Hartman
To make it easier for driver subsystems to work with attribute groups, create the
ATTRIBUTE_GROUPSmacro to remove some of the repetitive typing for the most common use for attribute groups.Signed-off-by Greg Kroah-Hartman <[email protected]>--- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/linux/sysfs.h +0
-0
include/linux/sysfs.h struct attribute_group { · line 97
Quoted 4 lines
include/linux/sysfs.h +1
-0@@ -94,6 +94,15 @@ struct attribute_group {#define __ATTR_IGNORE_LOCKDEP __ATTR#endif +#define ATTRIBUTE_GROUPS (name) \
Would it be possible to add is_visible as additional argument ?
Thanks,
Guenter
Quoted 15 lines
include/linux/sysfs.h +8
-0+static const struct attribute_group name##_group = { \ + .attrs = name##_attrs, \ +}; \ +static const struct attribute_group *name##_groups[] = { \ + &name##_group, \ +NULL , \ +} +#define attr_name (_attr) (_attr).attr.namestruct file ;Signature · 1 line
1.8.3.rc0.20.gb99dd2e
Quoted 18 lines · Guenter Roeck
Quoted 17 lines · Greg Kroah-Hartman
To make it easier for driver subsystems to work with attribute groups, create the
ATTRIBUTE_GROUPSmacro to remove some of the repetitive typing for the most common use for attribute groups.Signed-off-by Greg Kroah-Hartman <[email protected]>--- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/linux/sysfs.h +0
-0@@ -94,6 +94,15 @@ struct attribute_group {#define __ATTR_IGNORE_LOCKDEP __ATTR#endif
Quoted 3 lines
include/linux/sysfs.h struct attribute_group { · line 97
Quoted 1 line
include/linux/sysfs.h +1
-0+#define ATTRIBUTE_GROUPS (name) \Would it be possible to add
is_visibleas additional argument ?
I thought about the other options (multiple groups, is_visible, and bin_attrs), but those are almost all not the "normal" usage, so I figure it's worth the extra 6 lines of text if you want to support is_visible or binary attributes.
After converting all of the class code to use groups, it seems to match up with the defaults, but if in the future it's more popular than expected, I'll gladly add it.
thanks,
greg k-h
Quoted 19 lines · Greg Kroah-Hartman
Quoted 18 lines · Guenter Roeck
Quoted 17 lines · Greg Kroah-Hartman
To make it easier for driver subsystems to work with attribute groups, create the
ATTRIBUTE_GROUPSmacro to remove some of the repetitive typing for the most common use for attribute groups.Signed-off-by Greg Kroah-Hartman <[email protected]>--- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/linux/sysfs.h +0
-0@@ -94,6 +94,15 @@ struct attribute_group {#define __ATTR_IGNORE_LOCKDEP __ATTR#endif
Quoted 9 lines
Quoted 3 lines
include/linux/sysfs.h struct attribute_group { · line 97
Quoted 1 line
include/linux/sysfs.h +1
-0+#define ATTRIBUTE_GROUPS (name) \Would it be possible to add
is_visibleas additional argument ?I thought about the other options (multiple groups,
is_visible, andbin_attrs), but those are almost all not the "normal" usage, so I figure it's worth the extra 6 lines of text if you want to supportis_visibleor binary attributes.
Ok, fair enough.
Thanks,
Guenter