From: "Václav Kubernát" <kubernat@cesnet.cz>
To: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>,
linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: "Václav Kubernát" <kubernat@cesnet.cz>
Subject: [PATCH v5 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled
Date: Wed, 12 May 2021 03:30:49 +0200 [thread overview]
Message-ID: <20210512013052.903297-3-kubernat@cesnet.cz> (raw)
In-Reply-To: <20210512013052.903297-1-kubernat@cesnet.cz>
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
index 5d4c551df010..6e0ffbcf0d28 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -165,6 +165,9 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
switch (attr) {
case hwmon_fan_input:
+ if (!(data->fan_config[channel] & MAX31790_FAN_CFG_TACH_INPUT_EN))
+ return -ENODATA;
+
tach = read_reg_word(regmap, MAX31790_REG_TACH_COUNT(channel));
if (tach < 0)
return tach;
@@ -179,6 +182,11 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
*val = RPM_FROM_REG(tach, get_tach_period(data->fan_dynamics[channel]));
return 0;
case hwmon_fan_fault:
+ if (!(data->fan_config[channel] & 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.31.1
next prev parent reply other threads:[~2021-05-12 1:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 1:30 [PATCH v5 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-05-12 1:30 ` [PATCH v5 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
2021-05-12 1:32 ` Václav Kubernát
2021-05-18 14:59 ` Guenter Roeck
2021-05-19 23:11 ` Guenter Roeck
2021-05-12 1:30 ` Václav Kubernát [this message]
2021-05-12 1:30 ` [PATCH v5 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-05-12 1:30 ` [PATCH v5 5/5] hwmon: (max31790) Update documentation Václav Kubernát
2021-05-19 19:00 ` [PATCH v5 1/5] hwmon: (max31790) Rework to use regmap Guenter Roeck
2021-05-20 5:12 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210512013052.903297-3-kubernat@cesnet.cz \
--to=kubernat@cesnet.cz \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).