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 2/2] hwmon: (dell-smm) Add support for pwmX_fan_channel attribute
Date: Sat, 23 Jul 2022 05:38:20 +0200	[thread overview]
Message-ID: <20220723033820.22612-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20220723033820.22612-1-W_Armin@gmx.de>

The SMM interface does not differentiate between fan channels
and pwm channels, so each pwmX is associated with fanX_*.

Inform userspace programs of this with the pwmX_fan_channel
attribute.

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 Documentation/hwmon/dell-smm-hwmon.rst |  1 +
 drivers/hwmon/dell-smm-hwmon.c         | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/hwmon/dell-smm-hwmon.rst b/Documentation/hwmon/dell-smm-hwmon.rst
index e5d85e40972c..2b0651c3f7c5 100644
--- a/Documentation/hwmon/dell-smm-hwmon.rst
+++ b/Documentation/hwmon/dell-smm-hwmon.rst
@@ -38,6 +38,7 @@ fan[1-3]_min                    RO      Minimal Fan speed in RPM
 fan[1-3]_max                    RO      Maximal Fan speed in RPM
 fan[1-3]_target                 RO      Expected Fan speed in RPM
 pwm[1-3]                        RW      Control the fan PWM duty-cycle.
+pwm[1-3]_fan_channel            RO      Hints which PWM is connected to which fan
 pwm1_enable                     WO      Enable or disable automatic BIOS fan
                                         control (not supported on all laptops,
                                         see below for details).
diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 7f8d95dd2717..e6bf65d2ffc6 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -713,6 +713,11 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types
 			if (data->fan[channel])
 				return 0644;

+			break;
+		case hwmon_pwm_fan_channel:
+			if (data->fan[channel])
+				return 0444;
+
 			break;
 		case hwmon_pwm_enable:
 			if (data->auto_fan)
@@ -800,6 +805,10 @@ static int dell_smm_read(struct device *dev, enum hwmon_sensor_types type, u32 a

 			*val = clamp_val(ret * data->i8k_pwm_mult, 0, 255);

+			return 0;
+		case hwmon_pwm_fan_channel:
+			*val = channel + 1;
+
 			return 0;
 		default:
 			break;
@@ -943,9 +952,9 @@ static const struct hwmon_channel_info *dell_smm_info[] = {
 			   HWMON_F_TARGET
 			   ),
 	HWMON_CHANNEL_INFO(pwm,
-			   HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
-			   HWMON_PWM_INPUT,
-			   HWMON_PWM_INPUT
+			   HWMON_PWM_INPUT | HWMON_PWM_FAN_CHANNEL | HWMON_PWM_ENABLE,
+			   HWMON_PWM_INPUT | HWMON_PWM_FAN_CHANNEL,
+			   HWMON_PWM_INPUT | HWMON_PWM_FAN_CHANNEL
 			   ),
 	NULL
 };
--
2.30.2


  parent reply	other threads:[~2022-07-23  3:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23  3:38 [PATCH 0/2] hwmon: Add new " Armin Wolf
2022-07-23  3:38 ` [PATCH 1/2] hwmon: Add " Armin Wolf
2022-07-23 14:17   ` Guenter Roeck
2022-07-24  1:20     ` Armin Wolf
2022-07-24 14:44       ` Guenter Roeck
2022-07-24 16:06         ` Armin Wolf
2022-07-24 16:30           ` Guenter Roeck
2022-07-24 17:50             ` Armin Wolf
2022-07-23  3:38 ` Armin Wolf [this message]
2022-07-23 14:14   ` [PATCH 2/2] hwmon: (dell-smm) Add support for " 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=20220723033820.22612-3-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®