Skip to content

Commit e323b2d

Browse files
dtorgregkh
authored andcommitted
driver core: add device_{add|remove}_group() helpers
We have helpers that work with NULL terminated array of groups, but many drivers only create a single supplemental group, and do not want to declare a group array. Let's provide them with helpers working with a single group. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a7670d4 commit e323b2d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/device.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,22 @@ extern int __must_check device_add_groups(struct device *dev,
12051205
extern void device_remove_groups(struct device *dev,
12061206
const struct attribute_group **groups);
12071207

1208+
static inline int __must_check device_add_group(struct device *dev,
1209+
const struct attribute_group *grp)
1210+
{
1211+
const struct attribute_group *groups[] = { grp, NULL };
1212+
1213+
return device_add_groups(dev, groups);
1214+
}
1215+
1216+
static inline void device_remove_group(struct device *dev,
1217+
const struct attribute_group *grp)
1218+
{
1219+
const struct attribute_group *groups[] = { grp, NULL };
1220+
1221+
return device_remove_groups(dev, groups);
1222+
}
1223+
12081224
/*
12091225
* Platform "fixup" functions - allow the platform to have their say
12101226
* about devices and actions that the general device layer doesn't

0 commit comments

Comments
 (0)