mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/lenovo: thinkpad_acpi: add named speed presets to fan_write_cmd_speed
@ 2026-03-30 20:35 Даниил Булгарь
  2026-03-31  1:19 ` Mark Pearson
  0 siblings, 1 reply; 6+ messages in thread
From: Даниил Булгарь @ 2026-03-30 20:35 UTC (permalink / raw)
  To: hmh, mpearson-lenovo, Derek John Clark
  Cc: hansg, ilpo.jarvinen, ibm-acpi-devel, platform-driver-x86, linux-kernel

platform/x86/lenovo: thinkpad_acpi: add named speed presets to
fan_write_cmd_speed

The fan_write_cmd_speed() function had a TODO comment suggesting
support for named speed presets (low, medium, high). Implement
this by mapping the preset names to the existing fan_speed_presets
enum values, following the same strstarts() pattern used in
fan_write_cmd_level().
Signed-off-by: Daniil Bulgar <bulgardaniil18@gmail.com>
---
 drivers/platform/x86/lenovo/thinkpad_acpi.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 8982d92df..f10cebe11 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -7957,6 +7957,12 @@ enum fan_control_commands {
                         * and also watchdog cmd */
 };

+enum fan_speed_preset {
+    TPACPI_FAN_SPEED_LOW    = 65535 / 4,    /* 25% speed */
+    TPACPI_FAN_SPEED_MEDIUM    = 65535 / 2,    /* 50% speed */
+    TPACPI_FAN_SPEED_HIGH    = 65535,    /* 100% speed */
+};
+
 static bool fan_control_allowed;

 static enum fan_status_access_mode fan_status_access_mode;
@@ -9249,10 +9255,13 @@ static int fan_write_cmd_speed(const char *cmd, int *rc)
 {
     int speed;

-    /* TODO:
-    * Support speed <low> <medium> <high> ? */
-
-    if (sscanf(cmd, "speed %d", &speed) != 1)
+    if (strstarts(cmd, "speed low"))
+        speed = TPACPI_FAN_SPEED_LOW;
+    else if (strstarts(cmd, "speed medium"))
+        speed = TPACPI_FAN_SPEED_MEDIUM;
+    else if (strstarts(cmd, "speed high"))
+        speed = TPACPI_FAN_SPEED_HIGH;
+    else if (sscanf(cmd, "speed %d", &speed) != 1)
         return 0;

     *rc = fan_set_speed(speed);
-- 
2.53.0

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

end of thread, other threads:[~2026-04-09 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-30 20:35 [PATCH] platform/x86/lenovo: thinkpad_acpi: add named speed presets to fan_write_cmd_speed Даниил Булгарь
2026-03-31  1:19 ` Mark Pearson
2026-04-07 17:39   ` Mark Pearson
2026-04-07 19:05     ` [PATCH v2] platform/x86: thinkpad_acpi: remove obsolete TODO comment Daniil Bulgar
2026-04-07 19:07       ` Mark Pearson
2026-04-09 13:41       ` Ilpo Järvinen

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®