Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692306 > unrolled thread

[PATCH v2 3/7] driver core: add device_{add|remove}_group() helpers

Started byDmitry Torokhov <dmitry.torokhov@gmail.com>
First post2017-07-20 02:30 +0200
Last post2017-07-20 02:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 3/7] driver core: add device_{add|remove}_group() helpers Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-07-20 02:30 +0200

#1692306 — [PATCH v2 3/7] driver core: add device_{add|remove}_group() helpers

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-07-20 02:30 +0200
Subject[PATCH v2 3/7] driver core: add device_{add|remove}_group() helpers
Message-ID<u57vQ-7Pa-3@gated-at.bofh.it>
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>
---
 include/linux/device.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

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,
 extern void device_remove_groups(struct device *dev,
 				 const struct attribute_group **groups);
 
+static inline int __must_check device_add_group(struct device *dev,
+					const struct attribute_group *grp)
+{
+	const struct attribute_group *groups[] = { grp, NULL };
+
+	return device_add_groups(dev, groups);
+}
+
+static inline void device_remove_group(struct device *dev,
+				       const struct attribute_group *grp)
+{
+	const struct attribute_group *groups[] = { grp, NULL };
+
+	return device_remove_groups(dev, groups);
+}
+
 /*
  * Platform "fixup" functions - allow the platform to have their say
  * about devices and actions that the general device layer doesn't
-- 
2.14.0.rc0.284.gd933b75aa4-goog

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web