[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210316175503.1003051-3-kubernat@cesnet.cz>
Date: Tue, 16 Mar 2021 18:55:00 +0100
From: Václav Kubernát <kubernat@...net.cz>
To: unlisted-recipients:; (no To-header on input)
Cc: Václav Kubernát <kubernat@...net.cz>,
Jean Delvare <jdelvare@...e.com>,
Guenter Roeck <linux@...ck-us.net>,
Jonathan Corbet <corbet@....net>, linux-hwmon@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled
When fan speed input is disabled, it makes no sense to show values in
fan*_input and fan*_fault.
Signed-off-by: Václav Kubernát <kubernat@...net.cz>
---
drivers/hwmon/max31790.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
index d16b77472cc1..7b47797db471 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -168,6 +168,13 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
switch (attr) {
case hwmon_fan_input:
+ cfg = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel));
+ if (cfg < 0)
+ return cfg;
+
+ if (!(cfg & MAX31790_FAN_CFG_TACH_INPUT_EN))
+ return -ENODATA;
+
dynamics = read_reg_byte(regmap, MAX31790_REG_FAN_DYNAMICS(channel));
if (dynamics < 0)
return dynamics;
@@ -192,6 +199,15 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
*val = rpm;
return 0;
case hwmon_fan_fault:
+ cfg = read_reg_byte(regmap, MAX31790_REG_FAN_CONFIG(channel));
+ if (cfg < 0)
+ return cfg;
+
+ if (!(cfg & MAX31790_FAN_CFG_TACH_INPUT_EN)) {
+ *val = 0;
+ return 0;
+ }
+
if (channel > 6)
fault = read_reg_byte(regmap, MAX31790_REG_FAN_FAULT_STATUS2);
else
--
2.30.2
Powered by blists - more mailing lists