[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250423175040.784680-2-david.e.box@linux.intel.com>
Date: Wed, 23 Apr 2025 10:50:31 -0700
From: "David E. Box" <david.e.box@...ux.intel.com>
To: 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,
david.e.box@...ux.intel.com,
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: [PATCH 1/7] sysfs: Rename attribute group visibility macros
Update the naming of several macros to provide clearer semantics for
controlling group and attribute visibility per Dan Williams' suggestion.
Also, add transitional aliases mapping the old macro names to the new ones
so that driver code remains functional before changes are again made in a
future macro encapsulation patch. This approach ensures that when the
encapsulation work is applied, drivers will only need to be updated once
without breaking compatibility.
Suggested-by: Dan Williams <dan.j.williams@...el.com>
Signed-off-by: David E. Box <david.e.box@...ux.intel.com>
---
include/linux/sysfs.h | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 18f7e1fd093c..00dc88776f21 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -116,7 +116,7 @@ struct attribute_group {
#define SYSFS_GROUP_INVISIBLE 020000
/*
- * DEFINE_SYSFS_GROUP_VISIBLE(name):
+ * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name):
* A helper macro to pair with the assignment of ".is_visible =
* SYSFS_GROUP_VISIBLE(name)", that arranges for the directory
* associated with a named attribute_group to optionally be hidden.
@@ -142,7 +142,7 @@ struct attribute_group {
* return true;
* }
*
- * DEFINE_SYSFS_GROUP_VISIBLE(example);
+ * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(example);
*
* static struct attribute_group example_group = {
* .name = "example",
@@ -153,9 +153,9 @@ struct attribute_group {
* Note that it expects <name>_attr_visible and <name>_group_visible to
* be defined. For cases where individual attributes do not need
* separate visibility consideration, only entire group visibility at
- * once, see DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE().
+ * once, see DEFINE_SYSFS_GROUP_VISIBILITY().
*/
-#define DEFINE_SYSFS_GROUP_VISIBLE(name) \
+#define DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name) \
static inline umode_t sysfs_group_visible_##name( \
struct kobject *kobj, struct attribute *attr, int n) \
{ \
@@ -165,9 +165,9 @@ struct attribute_group {
}
/*
- * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name):
+ * DEFINE_SYSFS_GROUP_VISIBILITY(name):
* A helper macro to pair with SYSFS_GROUP_VISIBLE() that like
- * DEFINE_SYSFS_GROUP_VISIBLE() controls group visibility, but does
+ * DEFINE_SYSFS_GROUP_COMBO_VISIBILITY() controls group visibility, but does
* not require the implementation of a per-attribute visibility
* callback.
* Ex.
@@ -179,7 +179,7 @@ struct attribute_group {
* return true;
* }
*
- * DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(example);
+ * DEFINE_SYSFS_GROUP_VISIBILITY(example);
*
* static struct attribute_group example_group = {
* .name = "example",
@@ -187,7 +187,7 @@ struct attribute_group {
* .attrs = &example_attrs,
* };
*/
-#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) \
+#define DEFINE_SYSFS_GROUP_VISIBILITY(name) \
static inline umode_t sysfs_group_visible_##name( \
struct kobject *kobj, struct attribute *a, int n) \
{ \
@@ -197,12 +197,12 @@ struct attribute_group {
}
/*
- * Same as DEFINE_SYSFS_GROUP_VISIBLE, but for groups with only binary
+ * Same as DEFINE_SYSFS_GROUP_COMBO_VISIBILITY, but for groups with only binary
* attributes. If an attribute_group defines both text and binary
* attributes, the group visibility is determined by the function
* specified to is_visible() not is_bin_visible()
*/
-#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) \
+#define DEFINE_SYSFS_BIN_GROUP_COMBO_VISIBILITY(name) \
static inline umode_t sysfs_group_visible_##name( \
struct kobject *kobj, const struct bin_attribute *attr, int n) \
{ \
@@ -211,7 +211,7 @@ struct attribute_group {
return name##_attr_visible(kobj, attr, n); \
}
-#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) \
+#define DEFINE_SYSFS_BIN_GROUP_VISIBILITY(name) \
static inline umode_t sysfs_group_visible_##name( \
struct kobject *kobj, const struct bin_attribute *a, int n) \
{ \
@@ -220,6 +220,12 @@ struct attribute_group {
return a->mode; \
}
+/* Transitional aliases: so legacy code using old names continues to work */
+#define DEFINE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_COMBO_VISIBILITY(name)
+#define DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(name) DEFINE_SYSFS_GROUP_VISIBILITY(name)
+#define DEFINE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP_COMBO_VISIBILITY(name)
+#define DEFINE_SIMPLE_SYSFS_BIN_GROUP_VISIBLE(name) DEFINE_SYSFS_BIN_GROUP_VISIBILITY(name)
+
#define SYSFS_GROUP_VISIBLE(fn) sysfs_group_visible_##fn
/*
--
2.43.0
Powered by blists - more mailing lists