diff mbox series

[1/9] hwmon: Add helper hwmon_visible_0444

Message ID 8583cf5a-5495-476c-a309-169a83013aa9@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series hwmon: Add and use helper hwmon_visible_0444 | expand

Commit Message

Heiner Kallweit Oct. 9, 2024, 8:03 p.m. UTC
Several drivers simply return 0444 in their is_visible callback.
Add a helper in hwmon core for this use case to avoid code duplication.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/hwmon/hwmon.c | 7 +++++++
 include/linux/hwmon.h | 2 ++
 2 files changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 9c35c4d03..7c26e241e 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -108,6 +108,13 @@  static const struct attribute_group hwmon_dev_attr_group = {
 	.is_visible	= hwmon_dev_attr_is_visible,
 };
 
+umode_t hwmon_visible_0444(const void *drvdata, enum hwmon_sensor_types type,
+			   u32 attr, int channel)
+{
+	return 0444;
+}
+EXPORT_SYMBOL_GPL(hwmon_visible_0444);
+
 static const struct attribute_group *hwmon_dev_attr_groups[] = {
 	&hwmon_dev_attr_group,
 	NULL
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 5c6a421ad..ce38051b6 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -422,6 +422,8 @@  struct hwmon_ops {
 		     u32 attr, int channel, long val);
 };
 
+umode_t hwmon_visible_0444(const void *drvdata, enum hwmon_sensor_types type,
+			   u32 attr, int channel);
 /**
  * struct hwmon_channel_info - Channel information
  * @type:	Channel type.