[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <680994c499125_71fe294d3@dwillia2-xfh.jf.intel.com.notmuch>
Date: Wed, 23 Apr 2025 18:32:52 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: "David E. Box" <david.e.box@...ux.intel.com>, <corbet@....net>,
<bhelgaas@...gle.com>, <kuurtb@...il.com>, <hdegoede@...hat.com>,
<ilpo.jarvinen@...ux.intel.com>, <vkoul@...nel.org>,
<yung-chuan.liao@...ux.intel.com>, <pierre-louis.bossart@...ux.dev>,
<sanyog.r.kale@...el.com>, <gregkh@...uxfoundation.org>, <rafael@...nel.org>,
<dakr@...nel.org>, <dan.j.williams@...el.com>,
<andriy.shevchenko@...ux.intel.com>
CC: <linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-pci@...r.kernel.org>, <platform-driver-x86@...r.kernel.org>,
<Dell.Client.Kernel@...l.com>, <linux-sound@...r.kernel.org>
Subject: Re: [PATCH 2/7] sysfs: Introduce macros to simplify creation of
visible attribute groups
David E. Box wrote:
> Introduce macros to reduce boilerplate in attribute group definitions.
> Combine DEFINE_SYSFS_ATTRIBUTE_GROUP_[COMBO]_VISIBILITY() with attribute
> definitions in order to simplify group declarations involving visibility
> logic.
>
> Signed-off-by: David E. Box <david.e.box@...ux.intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
> include/linux/sysfs.h | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index 00dc88776f21..0804bffd6013 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -303,6 +303,30 @@ static const struct attribute_group _name##_group = { \
> }; \
> __ATTRIBUTE_GROUPS(_name)
>
> +#define NAMED_ATTRIBUTE_GROUP_VISIBLE(_name) \
> +DEFINE_SYSFS_GROUP_VISIBILITY(_name); \
> +static const struct attribute_group _name##_group = { \
> + .name = __stringify(_name), \
> + .attrs = _name##_attrs, \
> + .is_visible = SYSFS_GROUP_VISIBLE(_name), \
> +}
> +
> +#define NAMED_ATTRIBUTE_GROUPS_VISIBLE(_name) \
> +NAMED_ATTRIBUTE_GROUP_VISIBLE(_name); \
> +__ATTRIBUTE_GROUPS(_name)
> +
> +#define NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(_name) \
> +DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(_name); \
> +static const struct attribute_group _name##_group = { \
> + .name = __stringify(_name), \
> + .attrs = _name##_attrs, \
> + .is_visible = SYSFS_GROUP_VISIBLE(_name), \
> +}
> +
> +#define NAMED_ATTRIBUTE_GROUPS_COMBO_VISIBLE(_name) \
> +NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE(_name); \
> +__ATTRIBUTE_GROUPS(_name)
> +
Looks good to me, I like that this makes clear that it is setting {
.name } in the resulting group.
I would not mind a comment like "See DEFINE_SYSFS_GROUP_COMBO_VISIBILITY
for method definition requirements", but only add that as a follow-on
patch if someone else acks that idea.
Reviewed-by: Dan Williams <dan.j.williams@...el.com>
Powered by blists - more mailing lists