Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop

From: Rong Zhang

Date: Tue Nov 24 2026 - 09:11:43 EST


Hi Tom,

Thanks for working on this.

On Tue, 2026-11-24 at 18:39 +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.
>
> Only apply the cross check when the stop threshold is supported.
>
> Signed-off-by: huxiaoying <huxiaoying@xxxxxxxxxx>

FWIW:

Reviewed-by: Rong Zhang <i@xxxxxxxx>

A random thought: perhaps initializing charge_stop with 100 could make
the code cleaner?

Thanks,
Rong

> ---
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 8fc5569131f6..842045272ffa 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -9832,7 +9832,8 @@ static ssize_t tpacpi_battery_store(int what,
> /* valid values are [0, 99] */
> if (value > 99)
> return -EINVAL;
> - if (value > battery_info.batteries[battery].charge_stop)
> + if (battery_info.batteries[battery].stop_support &&
> + value > battery_info.batteries[battery].charge_stop)
> return -EINVAL;
> if (tpacpi_battery_set(THRESHOLD_START, battery, value))
> return -ENODEV;