mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: jdelvare@suse.com, linux@roeck-us.net
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] hwmon: (ftsteutates) Add support for fanX_fault attributes
Date: Thu,  5 Jan 2023 15:19:11 +0100	[thread overview]
Message-ID: <20230105141911.8040-4-W_Armin@gmx.de> (raw)
In-Reply-To: <20230105141911.8040-1-W_Armin@gmx.de>

The driver knows internally when a fan is not connected,
but does not export this knowledge to userspace. Use the
standard fanX_fault attributes to notify userspace if a
fan is not connected.

Tested on a Fujitsu DS3401-B1.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/ftsteutates.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c
index 0d8ab94250a9..25afd9167a34 100644
--- a/drivers/hwmon/ftsteutates.c
+++ b/drivers/hwmon/ftsteutates.c
@@ -356,6 +356,7 @@ static umode_t fts_is_visible(const void *devdata, enum hwmon_sensor_types type,
 	case hwmon_fan:
 		switch (attr) {
 		case hwmon_fan_input:
+		case hwmon_fan_fault:
 			return 0444;
 		case hwmon_fan_alarm:
 			return 0644;
@@ -411,6 +412,10 @@ static int fts_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
 		case hwmon_fan_alarm:
 			*val = !!(data->fan_alarm & BIT(channel));

+			return 0;
+		case hwmon_fan_fault:
+			*val = !(data->fan_present & BIT(channel));
+
 			return 0;
 		default:
 			break;
@@ -536,14 +541,14 @@ static const struct hwmon_channel_info *fts_info[] = {
 			   HWMON_T_INPUT | HWMON_T_ALARM | HWMON_T_FAULT
 			   ),
 	HWMON_CHANNEL_INFO(fan,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM,
-			   HWMON_F_INPUT | HWMON_F_ALARM
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT,
+			   HWMON_F_INPUT | HWMON_F_ALARM | HWMON_F_FAULT
 			   ),
 	HWMON_CHANNEL_INFO(pwm,
 			   HWMON_PWM_AUTO_CHANNELS_TEMP,
--
2.30.2


  parent reply	other threads:[~2023-01-05 14:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 14:19 [PATCH 0/3] Convert to *_with_info() API Armin Wolf
2023-01-05 14:19 ` [PATCH 1/3] hwmon: (ftsteutates) Convert to devm_hwmon_device_register_with_info() Armin Wolf
2023-01-05 14:19 ` [PATCH 2/3] hwmon: (ftsteutates) Replace fanX_source with pwmX_auto_channels_temp Armin Wolf
2023-01-05 14:19 ` Armin Wolf [this message]
2023-01-05 14:57 ` [PATCH 0/3] Convert to *_with_info() API Guenter Roeck
2023-01-05 22:36   ` Armin Wolf

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=20230105141911.8040-4-W_Armin@gmx.de \
    --to=w_armin@gmx.de \
    --cc=jdelvare@suse.com \
    --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®