@@ -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
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@cesnet.cz> --- drivers/hwmon/max31790.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)