linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] sysfs: Introduce macros for attribute groups with visibility control
@ 2025-04-23 17:50 David E. Box
  2025-04-23 17:50 ` [PATCH 1/7] sysfs: Rename attribute group visibility macros David E. Box
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: David E. Box @ 2025-04-23 17:50 UTC (permalink / raw)
  To: corbet, bhelgaas, kuurtb, hdegoede, ilpo.jarvinen, vkoul,
	yung-chuan.liao, pierre-louis.bossart, sanyog.r.kale, gregkh,
	rafael, dakr, david.e.box, dan.j.williams, andriy.shevchenko
  Cc: linux-doc, linux-kernel, linux-pci, platform-driver-x86,
	Dell.Client.Kernel, linux-sound

The ATTRIBUTE_GROUP() helper does not support adding an .is_visible
function for visibility control. With the introduction of
SYSFS_GROUP_VISIBLE, DEFINE_SYSFS_GROUP_VISIBLE, and related macros,
attribute group definitions can now fully encapsulate visibility logic
while eliminating boilerplate code.

The following new macros are introduced:

        NAMED_ATTRIBUTE_GROUP_VISIBLE()
        NAMED_ATTRIBUTE_GROUPS_VISIBLE()
        NAMED_ATTRIBUTE_GROUP_COMBO_VISIBLE()
        NAMED_ATTRIBUTE_GROUPS_COMBO_VISIBLE()

This isn’t just a cleanup effort — I plan to use these macros in new driver
code I'm working on, and wanted to avoid having to open-code these common
visibility patterns yet again. Documenting and generalizing them now will
help avoid duplication and make future code easier to read and maintain.

These macros integrate visibility logic directly into attribute group
definitions, improving readability and maintainability. The
DEFINE[_SIMPLE_]ATTRIBUTE_GROUP_VISIBLE() macros current have four users.
Two out of them could be modified. The usbtouchscreen driver uses the @name
field which isn't supported by ATTRIBUTE_GROUPS(). But for the ones that
could be modified the diffstat was significant:

 drivers/pci/doe.c                              |  2 +-
 drivers/platform/x86/dell/alienware-wmi-base.c | 23 +++++++++--------------
 drivers/platform/x86/dell/alienware-wmi-wmax.c |  7 ++++---
 drivers/soundwire/sysfs_slave.c                | 32 +++++++++++++-------------------
 4 files changed, 27 insertions(+), 37 deletions(-)

David E. Box (7):
  sysfs: Rename attribute group visibility macros
  sysfs: Introduce macros to simplify creation of visible attribute
    groups
  docs: sysfs.rst: document additional attribute group macros
  pci: doe: Replace sysfs visibility macro
  soundwire: sysfs: Use ATTRIBUTE_GROUP_VISIBLE()
  platform/x86/dell: alienware-wmi: update sysfs visibility macros
  sysfs: Remove transitional attribute group alias macros

 Documentation/filesystems/sysfs.rst           | 244 ++++++++++++++++++
 drivers/pci/doe.c                             |   2 +-
 .../platform/x86/dell/alienware-wmi-base.c    |  23 +-
 .../platform/x86/dell/alienware-wmi-wmax.c    |   7 +-
 drivers/soundwire/sysfs_slave.c               |  32 +--
 include/linux/sysfs.h                         |  46 +++-
 6 files changed, 306 insertions(+), 48 deletions(-)


base-commit: 9c32cda43eb78f78c73aee4aa344b777714e259b
-- 
2.43.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-04-26 13:07 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 17:50 [PATCH 0/7] sysfs: Introduce macros for attribute groups with visibility control David E. Box
2025-04-23 17:50 ` [PATCH 1/7] sysfs: Rename attribute group visibility macros David E. Box
2025-04-24  1:26   ` Dan Williams
2025-04-23 17:50 ` [PATCH 2/7] sysfs: Introduce macros to simplify creation of visible attribute groups David E. Box
2025-04-24  1:32   ` Dan Williams
2025-04-23 17:50 ` [PATCH 3/7] docs: sysfs.rst: document additional attribute group macros David E. Box
2025-04-24  1:34   ` Dan Williams
2025-04-23 17:50 ` [PATCH 4/7] pci: doe: Replace sysfs visibility macro David E. Box
2025-04-24  1:35   ` Dan Williams
2025-04-25 10:57   ` Ilpo Järvinen
2025-04-25 18:13     ` David E. Box
2025-04-26 13:06       ` Ilpo Järvinen
2025-04-23 17:50 ` [PATCH 5/7] soundwire: sysfs: Use ATTRIBUTE_GROUP_VISIBLE() David E. Box
2025-04-24  1:37   ` Dan Williams
2025-04-23 17:50 ` [PATCH 6/7] platform/x86/dell: alienware-wmi: update sysfs visibility macros David E. Box
2025-04-23 18:31   ` Kurt Borja
2025-04-24  3:01   ` Dan Williams
2025-04-23 17:50 ` [PATCH 7/7] sysfs: Remove transitional attribute group alias macros David E. Box
2025-04-24  3:02   ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).