mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Даниил Булгарь" <bulgardaniil18@gmail.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	ibm-acpi-devel@lists.sourceforge.net,
	"platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86/lenovo: thinkpad_acpi: add named speed presets to fan_write_cmd_speed
Date: Mon, 30 Mar 2026 21:19:32 -0400	[thread overview]
Message-ID: <096ee581-2c27-4746-bc7e-1d699a952764@app.fastmail.com> (raw)
In-Reply-To: <CAMPU55i_MPW_MHBsBfbnrO7T5Q68q1QmNgLVBPiqoh30kGw4Pw@mail.gmail.com>

Hi Daniil

On Mon, Mar 30, 2026, at 4:35 PM, Даниил Булгарь wrote:
> 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

I'd never noticed that TODO :)

No issues with the code but I'd like to check with the thermal team if those are better ways of determining the ranges. I've got a feeling that they probably aren't. 
Fans don't go that high (or low) during operation so I wonder if there are better 'ranges' to be used (though it might be platform dependent too)

I'll ask if there is any guidance on it.

Mark


  reply	other threads:[~2026-03-31  1:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 20:35 Даниил Булгарь
2026-03-31  1:19 ` Mark Pearson [this message]
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

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=096ee581-2c27-4746-bc7e-1d699a952764@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=bulgardaniil18@gmail.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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®