mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Tom Hu" <huxiaoying@kylinos.cn>, linux-kernel@vger.kernel.org
Cc: "Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	"Rong Zhang" <i@rong.moe>, "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	xiaoying_hu@126.com
Subject: Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop
Date: Tue, 24 Nov 2026 13:00:29 -0500	[thread overview]
Message-ID: <6066c701-55c8-494f-9348-f9835b258b44@app.fastmail.com> (raw)
In-Reply-To: <20261124103946.897642-2-huxiaoying@kylinos.cn>


On Tue, Nov 24, 2026, at 5:39 AM, Tom Hu wrote:
> From: huxiaoying <huxiaoying@kylinos.cn>
>
> 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@kylinos.cn>
> ---
>  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;
> -- 

Looks good to me.
Out of curiousity - have you seen this happen on any actual HW? If you did I think it would be a FW bug as having a start threshold and not a stop threshold would be definitely odd.

Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark

  parent reply	other threads:[~2026-11-24 18:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 10:39 [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied Tom Hu
2026-11-24 10:39 ` [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop Tom Hu
2026-11-24 14:02   ` Rong Zhang
2026-11-24 18:00   ` Mark Pearson [this message]
2026-11-24 14:02 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied Rong Zhang

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=6066c701-55c8-494f-9348-f9835b258b44@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=hmh@hmh.eng.br \
    --cc=huxiaoying@kylinos.cn \
    --cc=i@rong.moe \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=xiaoying_hu@126.com \
    /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®