diff mbox series

[v3,1/2] hwmon: (core) Add support for power fault attribute

Message ID 20240412160857.79858-1-W_Armin@gmx.de (mailing list archive)
State Superseded, archived
Headers show
Series [v3,1/2] hwmon: (core) Add support for power fault attribute | expand

Commit Message

Armin Wolf April 12, 2024, 4:08 p.m. UTC
Power sensor driver might want to signal that the power
value is not usable. Add a new power fault attribute to
report such failures.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Changes since v2:
- added patch
---
 Documentation/ABI/testing/sysfs-class-hwmon | 9 +++++++++
 drivers/hwmon/hwmon.c                       | 1 +
 include/linux/hwmon.h                       | 2 ++
 3 files changed, 12 insertions(+)

--
2.39.2
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-class-hwmon b/Documentation/ABI/testing/sysfs-class-hwmon
index cfd0d0bab483..ed01d43d2491 100644
--- a/Documentation/ABI/testing/sysfs-class-hwmon
+++ b/Documentation/ABI/testing/sysfs-class-hwmon
@@ -882,6 +882,15 @@  Description:

 		RW

+What:		/sys/class/hwmon/hwmonX/powerY_fault
+Description:
+		Reports a power sensor failure.
+
+		- 1: Failed
+		- 0: Ok
+
+		RO
+
 What:		/sys/class/hwmon/hwmonX/powerY_rated_min
 Description:
 		Minimum rated power.
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 3b259c425ab7..6150d64f5c4c 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -560,6 +560,7 @@  static const char * const hwmon_power_attr_templates[] = {
 	[hwmon_power_crit] = "power%d_crit",
 	[hwmon_power_label] = "power%d_label",
 	[hwmon_power_alarm] = "power%d_alarm",
+	[hwmon_power_fault] = "power%d_fault",
 	[hwmon_power_cap_alarm] = "power%d_cap_alarm",
 	[hwmon_power_min_alarm] = "power%d_min_alarm",
 	[hwmon_power_max_alarm] = "power%d_max_alarm",
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index edf96f249eb5..00122e565dbf 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -237,6 +237,7 @@  enum hwmon_power_attributes {
 	hwmon_power_max_alarm,
 	hwmon_power_lcrit_alarm,
 	hwmon_power_crit_alarm,
+	hwmon_power_fault,
 	hwmon_power_rated_min,
 	hwmon_power_rated_max,
 };
@@ -270,6 +271,7 @@  enum hwmon_power_attributes {
 #define HWMON_P_MAX_ALARM		BIT(hwmon_power_max_alarm)
 #define HWMON_P_LCRIT_ALARM		BIT(hwmon_power_lcrit_alarm)
 #define HWMON_P_CRIT_ALARM		BIT(hwmon_power_crit_alarm)
+#define HWMON_P_FAULT			BIT(hwmon_power_fault)
 #define HWMON_P_RATED_MIN		BIT(hwmon_power_rated_min)
 #define HWMON_P_RATED_MAX		BIT(hwmon_power_rated_max)