All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (dell-smm) Show fan_max param in sysfs
@ 2021-09-03 14:24 W_Armin
  2021-09-03 14:49 ` Pali Rohár
  0 siblings, 1 reply; 5+ messages in thread
From: W_Armin @ 2021-09-03 14:24 UTC (permalink / raw)
  To: pali; +Cc: linux, jdelvare, linux-hwmon

From: Armin Wolf <W_Armin@gmx.de>

For allowing tools like i8kutils to query the fan state
without having to rely on the deprecated /proc/i8k interface,
they need to scale the pwm values (0 - 255) back to the
real hardware values (0 - 2/3).
Show fan_max in sysfs to allow for such a scenario.

Tested on a Dell Latitude C600.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/dell-smm-hwmon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 774c1b0715d9..6d3fd4f0f99d 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -107,7 +107,7 @@ module_param(fan_mult, uint, 0);
 MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with (default: autodetect)");

 static uint fan_max;
-module_param(fan_max, uint, 0);
+module_param(fan_max, uint, 0444);
 MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed (default: autodetect)");

 struct smm_regs {
@@ -1245,7 +1245,10 @@ static int __init dell_smm_probe(struct platform_device *pdev)
 			fan_max = conf->fan_max;
 	}

-	data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;	/* Must not be 0 */
+	if (!fan_max)	/* Must not be 0*/
+		fan_max = I8K_FAN_HIGH;
+
+	data->i8k_fan_max = fan_max;
 	data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);

 	fan_control = dmi_first_match(i8k_whitelist_fan_control);
--
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-03 17:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 14:24 [PATCH] hwmon: (dell-smm) Show fan_max param in sysfs W_Armin
2021-09-03 14:49 ` Pali Rohár
2021-09-03 14:59   ` Guenter Roeck
2021-09-03 15:40     ` Armin Wolf
2021-09-03 17:05       ` Guenter Roeck

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.