From: "Václav Kubernát" <kubernat@cesnet.cz>
To: unlisted-recipients:; (no To-header on input)
Cc: "Václav Kubernát" <kubernat@cesnet.cz>,
"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
Subject: [PATCH v2 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled
Date: Tue, 16 Mar 2021 18:55:00 +0100 [thread overview]
Message-ID: <20210316175503.1003051-3-kubernat@cesnet.cz> (raw)
In-Reply-To: <20210316175503.1003051-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 | 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
next prev parent reply other threads:[~2021-03-16 17:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 17:54 [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-03-16 17:54 ` [PATCH v2 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
2021-03-16 17:55 ` Václav Kubernát [this message]
2021-03-16 17:55 ` [PATCH v2 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-03-16 17:55 ` [PATCH v2 5/5] hwmon: (max31790) Update documentation Václav Kubernát
2021-03-16 18:11 ` [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-03-17 5:12 ` Dan Carpenter
2021-03-18 9:56 ` Václav Kubernát
[not found] ` <20210329222704.GA223476@roeck-us.net>
2021-03-30 3:43 ` Václav Kubernát
2021-04-13 2:59 Václav Kubernát
2021-04-13 2:59 ` [PATCH v2 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled Václav Kubernát
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=20210316175503.1003051-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
all inboxes | Powered by JetHome®