aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2017-07-19 20:24:32 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-07-22 05:59:23 -0400
commite323b2dddc1ce7ea7f032c986c012a04d5977dc8 (patch)
tree86b6f483126bcd2e0845cbb4d2aeafe11ebdeca1
parenta7670d425b75f9e44b7d4d0aea04f4a6d5f34291 (diff)
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 <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/device.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 10cf209a4e82..7698a513b35e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1205,6 +1205,22 @@ extern int __must_check device_add_groups(struct device *dev,
1205extern void device_remove_groups(struct device *dev, 1205extern void device_remove_groups(struct device *dev,
1206 const struct attribute_group **groups); 1206 const struct attribute_group **groups);
1207 1207
1208static 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
1216static 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
1208/* 1224/*
1209 * Platform "fixup" functions - allow the platform to have their say 1225 * Platform "fixup" functions - allow the platform to have their say
1210 * about devices and actions that the general device layer doesn't 1226 * about devices and actions that the general device layer doesn't