Re: [PATCH v3 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported
From: Rong Zhang
Date: Thu Nov 26 2026 - 07:22:47 EST
Hi Tom,
On Thu, 2026-11-26 at 09:10 +0800, Tom Hu wrote:
> From: huxiaoying <huxiaoying@xxxxxxxxxx>
>
> When the EC does not provide GET_STOP, stop_support stays clear and the
> cached charge_stop is never probed, so it remains 0. charge_start is
> still validated against that value, which rejects every level above 0
> even though the start threshold is supported.
>
> Default the cached charge_stop to 100 in tpacpi_battery_probe(). The
> store path already limits charge_start to [0, 99], so the
> `value > charge_stop` cross check can then never trigger when no stop
> threshold is known, and stop_support does not have to be consulted in
> that path. A successful GET_STOP probe overwrites the default with the
> value reported by the EC.
>
> Suggested-by: Rong Zhang <i@xxxxxxxx>
> Link: https://lore.kernel.org/all/8aceee902d146619d2d5b92b84942baeb27d111f.camel@xxxxxxxx/
> Reviewed-by: Rong Zhang <i@xxxxxxxx>
> Reviewed-by: Reviewed-by: Mark Pearson <mpearson-lenovo@xxxxxxxxx>
You didn't fix the corrupted tag, but claimed it as fixed in your
previous reply!?
Thanks,
Rong
> Signed-off-by: huxiaoying <huxiaoying@xxxxxxxxxx>
>
> Changes in v3:
> - Add the missing Link: tag after Suggested-by (Rong Zhang).
> - Fix the duplicated "Reviewed-by:" prefix on Mark Pearson's tag.
> - No code changes.
>
> Changes in v2:
> - Default charge_stop to 100 in tpacpi_battery_probe() instead of
> guarding the cross check with stop_support
> ---
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 8fc5569131f6..0c27e0b74b48 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -9698,6 +9698,14 @@ static int tpacpi_battery_probe(int battery)
> memset(&battery_info.batteries[battery], 0,
> sizeof(battery_info.batteries[battery]));
>
> + /*
> + * If the EC does not provide GET_STOP, stop_support stays clear and
> + * charge_stop is never probed. Default it to 100 (no upper limit)
> + * so that the cross check in tpacpi_battery_store() does not reject
> + * every charge_start value.
> + */
> + battery_info.batteries[battery].charge_stop = 100;
> +
> /*
> * 1) Get the current start threshold
> * 2) Check for support