From: Rong Zhang <i@rong.moe>
To: Tom Hu <huxiaoying@kylinos.cn>,
Mark Pearson <mpearson-lenovo@squebb.ca>,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org
Cc: "Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
"Derek J . Clark" <derekjohn.clark@gmail.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
xiaoying_hu@126.com
Subject: Re: [PATCH v2 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied
Date: Wed, 25 Nov 2026 22:09:20 +0800 [thread overview]
Message-ID: <5f8c406436d18dff63f209a4cb893f5c835293b2.camel@rong.moe> (raw)
In-Reply-To: <20261125125252.38003-2-huxiaoying@kylinos.cn>
Hi Tom,
On Wed, 2026-11-25 at 20:52 +0800, Tom Hu wrote:
> From: huxiaoying <huxiaoying@kylinos.cn>
>
> The charge_stop_threshold store writes the new value into the cached
> battery_info before the EC has accepted it. If the ACPI call fails,
> the cache and the hardware disagree, and subsequent charge_start
> writes are validated against the stale-not-applied value.
>
> Move the cache update after a successful EC write and report -ENODEV
> on failure, matching the charge_start path.
>
> Reviewed-by: Rong Zhang <i@rong.moe>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Please add a Fixes: tag. See my reply to v1.
Thanks,
Rong
> Signed-off-by: huxiaoying <huxiaoying@kylinos.cn>
> ---
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 4f81855ad721..8fc5569131f6 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -9847,16 +9847,15 @@ static ssize_t tpacpi_battery_store(int what,
> return -EINVAL;
> if (value < battery_info.batteries[battery].charge_start)
> return -EINVAL;
> - battery_info.batteries[battery].charge_stop = value;
> /*
> * When 100 is passed to stop, we need to flip
> * it to 0 as that the EC understands that as
> * "Default", which will charge to 100%
> */
> - if (value == 100)
> - value = 0;
> - if (tpacpi_battery_set(THRESHOLD_STOP, battery, value))
> - return -EINVAL;
> + if (tpacpi_battery_set(THRESHOLD_STOP, battery,
> + value == 100 ? 0 : value))
> + return -ENODEV;
> + battery_info.batteries[battery].charge_stop = value;
> return count;
> default:
> pr_crit("Wrong parameter: %d", what);
next prev parent reply other threads:[~2026-11-25 14:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 10:39 [PATCH " 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
2026-11-25 12:52 ` Tom Hu
2026-11-25 12:52 ` [PATCH v2 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied Tom Hu
2026-11-25 14:09 ` Rong Zhang [this message]
2026-11-25 12:52 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported Tom Hu
2026-11-25 14:10 ` Rong Zhang
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=5f8c406436d18dff63f209a4cb893f5c835293b2.camel@rong.moe \
--to=i@rong.moe \
--cc=derekjohn.clark@gmail.com \
--cc=hansg@kernel.org \
--cc=hmh@hmh.eng.br \
--cc=huxiaoying@kylinos.cn \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--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®