It would be indeed better if userspace software like pwmconfig would
use an internal list containing the names of all hwmon chips for which
the pwm to fan mappings are known.
I will add a note to the documentation of dell-smm-hwmon about the
pwm to fan mapping so userspace software knows about this.
Sorry for bothering you.
Armin Wolf
In contrast, many firmware-based chips do know which pwm channel
output controls which
fan channel. One example might be the dell-smm-hwmon driver and the
gpio-fan driver.
In this case, making the attribute RO would indeed make sense.
Unless the attribute is used to configure the chip, it does not make
sense
in the first place. Also note that gpio-fan is usually configured using
devicetree properties, _and_ it only has a single set of fan/pwm
properties,
so a sysfs attribute would always return 1 and make make even less
sense there.
Guenter
Armin Wolf
---
Documentation/ABI/testing/sysfs-class-hwmon | 8 ++++++++
Documentation/hwmon/sysfs-interface.rst | 3 +++
drivers/hwmon/hwmon.c | 1 +
include/linux/hwmon.h | 2 ++
4 files changed, 14 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-hwmon
b/Documentation/ABI/testing/sysfs-class-hwmon
index 7271781a23b2..f3d653bcf736 100644
--- a/Documentation/ABI/testing/sysfs-class-hwmon
+++ b/Documentation/ABI/testing/sysfs-class-hwmon
@@ -315,6 +315,14 @@ Description:
RW
+What: /sys/class/hwmon/hwmonX/pwmY_fan_channel
+Description:
+ Select which fan channel is controlled by this PWM output.
+
+ Valid fan channel/PWM output combinations are chip-dependent.
+
+ RW
+
What: /sys/class/hwmon/hwmonX/pwmY_auto_channels_temp
Description:
Select which temperature channels affect this PWM output in
diff --git a/Documentation/hwmon/sysfs-interface.rst
b/Documentation/hwmon/sysfs-interface.rst
index 209626fb2405..17fcec03d3c5 100644
--- a/Documentation/hwmon/sysfs-interface.rst
+++ b/Documentation/hwmon/sysfs-interface.rst
@@ -209,6 +209,9 @@ PWM
`pwm[1-*]_freq`
Base PWM frequency in Hz.
+`pwm[1-*]_fan_channel`
+ Select which fan channel is controlled by this PWM
output.
+
`pwm[1-*]_auto_channels_temp`
Select which temperature channels affect this PWM output in
auto mode.
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index 2e2cd79d89eb..8c2d7574c461 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -604,6 +604,7 @@ static const char * const
hwmon_pwm_attr_templates[] = {
[hwmon_pwm_enable] = "pwm%d_enable",
[hwmon_pwm_mode] = "pwm%d_mode",
[hwmon_pwm_freq] = "pwm%d_freq",
+ [hwmon_pwm_fan_channel] = "pwm%d_fan_channel",
[hwmon_pwm_auto_channels_temp] = "pwm%d_auto_channels_temp",
};
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 14325f93c6b2..9d40cc1e520f 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -332,6 +332,7 @@ enum hwmon_pwm_attributes {
hwmon_pwm_enable,
hwmon_pwm_mode,
hwmon_pwm_freq,
+ hwmon_pwm_fan_channel,
hwmon_pwm_auto_channels_temp,
};
@@ -339,6 +340,7 @@ enum hwmon_pwm_attributes {
#define HWMON_PWM_ENABLE BIT(hwmon_pwm_enable)
#define HWMON_PWM_MODE BIT(hwmon_pwm_mode)
#define HWMON_PWM_FREQ BIT(hwmon_pwm_freq)
+#define HWMON_PWM_FAN_CHANNEL BIT(hwmon_pwm_fan_channel)
#define HWMON_PWM_AUTO_CHANNELS_TEMP
BIT(hwmon_pwm_auto_channels_temp)
enum hwmon_intrusion_attributes {
--
2.30.2