Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755348AbdGTAZw (ORCPT ); Wed, 19 Jul 2017 20:25:52 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34001 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754484AbdGTAYl (ORCPT ); Wed, 19 Jul 2017 20:24:41 -0400 From: Dmitry Torokhov To: Greg Kroah-Hartman Cc: htejun@gmail.com, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH v2 3/7] driver core: add device_{add|remove}_group() helpers Date: Wed, 19 Jul 2017 17:24:32 -0700 Message-Id: <20170720002436.29309-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.14.0.rc0.284.gd933b75aa4-goog In-Reply-To: <20170720002436.29309-1-dmitry.torokhov@gmail.com> References: <20170720002436.29309-1-dmitry.torokhov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1332 Lines: 38 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 --- 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