All of lore.kernel.org
 help / color / mirror / Atom feed
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 v4 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled
Date: Mon, 26 Apr 2021 14:37:47 +0200	[thread overview]
Message-ID: <20210426123749.899654-3-kubernat@cesnet.cz> (raw)
In-Reply-To: <20210426123749.899654-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 82d7b8518743..842749482ba4 100644
--- a/drivers/hwmon/max31790.c
+++ b/drivers/hwmon/max31790.c
@@ -167,6 +167,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;
@@ -181,6 +184,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


  parent reply	other threads:[~2021-04-26 12:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  2:59 [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
     [not found]   ` <20210419223340.GA229491@roeck-us.net>
2021-04-22  0:26     ` 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
2021-04-13  2:59 ` [PATCH v2 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 5/5] hwmon: (max31790) Update documentation Václav Kubernát
2021-04-13  3:10 ` [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-04-22  1:27 ` Guenter Roeck
2021-04-23 10:55   ` Václav Kubernát
2021-04-26 12:46   ` Václav Kubernát
2021-04-26 14:17     ` Guenter Roeck
2021-04-26 14:29       ` Václav Kubernát
2021-04-26 14:35         ` Guenter Roeck
2021-04-26 12:37 ` [PATCH v4 " Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
2021-04-26 12:37   ` Václav Kubernát [this message]
2021-04-26 12:37   ` [PATCH v4 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 5/5] hwmon: (max31790) Update documentation 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=20210426123749.899654-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.