* [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied
@ 2026-11-24 10:39 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 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied Rong Zhang
0 siblings, 2 replies; 10+ messages in thread
From: Tom Hu @ 2026-11-24 10:39 UTC (permalink / raw)
To: linux-kernel
Cc: hmh, mpearson-lenovo, derekjohn.clark, i, hansg, ilpo.jarvinen,
platform-driver-x86, xiaoying_hu, huxiaoying
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.
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);
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop
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 ` Tom Hu
2026-11-24 14:02 ` Rong Zhang
2026-11-24 18:00 ` Mark Pearson
2026-11-24 14:02 ` [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied Rong Zhang
1 sibling, 2 replies; 10+ messages in thread
From: Tom Hu @ 2026-11-24 10:39 UTC (permalink / raw)
To: linux-kernel
Cc: hmh, mpearson-lenovo, derekjohn.clark, i, hansg, ilpo.jarvinen,
platform-driver-x86, xiaoying_hu, huxiaoying
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;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop
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
1 sibling, 0 replies; 10+ messages in thread
From: Rong Zhang @ 2026-11-24 14:02 UTC (permalink / raw)
To: Tom Hu, linux-kernel
Cc: hmh, mpearson-lenovo, derekjohn.clark, hansg, ilpo.jarvinen,
platform-driver-x86, xiaoying_hu
Hi Tom,
Thanks for working on this.
On Tue, 2026-11-24 at 18:39 +0800, 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>
FWIW:
Reviewed-by: Rong Zhang <i@rong.moe>
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;
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop
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
1 sibling, 1 reply; 10+ messages in thread
From: Mark Pearson @ 2026-11-24 18:00 UTC (permalink / raw)
To: Tom Hu, linux-kernel
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Rong Zhang,
Hans de Goede, Ilpo Järvinen, platform-driver-x86,
xiaoying_hu
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] platform/x86: thinkpad_acpi: Only check charge_start against a known charge_stop
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 12:52 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported Tom Hu
0 siblings, 2 replies; 10+ messages in thread
From: Tom Hu @ 2026-11-25 12:52 UTC (permalink / raw)
To: Mark Pearson, linux-kernel, platform-driver-x86, Rong Zhang
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Hans de Goede,
Ilpo Järvinen, xiaoying_hu
Hi Rong, Mark,
Thanks for the reviews.
On 2026-11-24, Rong Zhang wrote:
> A random thought: perhaps initializing charge_stop with 100 could make
> the code cleaner?
Good idea, Since charge_start is already limited to [0, 99] earlier in the
store path, defaulting charge_stop to 100 when GET_STOP is not available makes
the existing `value > charge_stop` check a no-op for such machines, and the extra
stop_support condition is not needed.
The v2 I'm about to send.
On 2026-11-24, Mark Pearson wrote:
> Have you seen this happen on any actual HW?
Not on hardware I have access to; I agree a firmware exposing GET_START but not GET_STOP
is unusual, so the patch is mostly hardening, but the current behaviour (rejecting every charge_start > 0)
is wrong either way, so I think it is worth fixing.
Thanks,
Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied
2026-11-25 12:52 ` Tom Hu
@ 2026-11-25 12:52 ` Tom Hu
2026-11-25 14:09 ` Rong Zhang
2026-11-25 12:52 ` [PATCH v2 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported Tom Hu
1 sibling, 1 reply; 10+ messages in thread
From: Tom Hu @ 2026-11-25 12:52 UTC (permalink / raw)
To: Mark Pearson, linux-kernel, platform-driver-x86, Rong Zhang
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Hans de Goede,
Ilpo Järvinen, xiaoying_hu
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>
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);
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v2 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied
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
0 siblings, 0 replies; 10+ messages in thread
From: Rong Zhang @ 2026-11-25 14:09 UTC (permalink / raw)
To: Tom Hu, Mark Pearson, linux-kernel, platform-driver-x86
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Hans de Goede,
Ilpo Järvinen, xiaoying_hu
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);
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported
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 12:52 ` Tom Hu
2026-11-25 14:10 ` Rong Zhang
1 sibling, 1 reply; 10+ messages in thread
From: Tom Hu @ 2026-11-25 12:52 UTC (permalink / raw)
To: Mark Pearson, linux-kernel, platform-driver-x86, Rong Zhang
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Hans de Goede,
Ilpo Järvinen, xiaoying_hu
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.
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@rong.moe>
Reviewed-by: Rong Zhang <i@rong.moe>
Reviewed-by: Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: huxiaoying <huxiaoying@kylinos.cn>
---
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
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] platform/x86: thinkpad_acpi: Default charge_stop to 100 when unsupported
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
0 siblings, 0 replies; 10+ messages in thread
From: Rong Zhang @ 2026-11-25 14:10 UTC (permalink / raw)
To: Tom Hu, Mark Pearson, linux-kernel, platform-driver-x86
Cc: Henrique de Moraes Holschuh, Derek J . Clark, Hans de Goede,
Ilpo Järvinen, xiaoying_hu
Hi Tom,
On Wed, 2026-11-25 at 20:52 +0800, 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.
>
> 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@rong.moe>
A Suggested-by: tag is usually followed by a Link: tag.
> Reviewed-by: Rong Zhang <i@rong.moe>
> Reviewed-by: Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
The tag is corrupted.
Thanks,
Rong
> Signed-off-by: huxiaoying <huxiaoying@kylinos.cn>
> ---
> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] platform/x86: thinkpad_acpi: Update charge_stop only after it was applied
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
1 sibling, 0 replies; 10+ messages in thread
From: Rong Zhang @ 2026-11-24 14:02 UTC (permalink / raw)
To: Tom Hu, linux-kernel
Cc: hmh, mpearson-lenovo, derekjohn.clark, hansg, ilpo.jarvinen,
platform-driver-x86, xiaoying_hu
Hi Tom,
Thanks for working on this.
On Tue, 2026-11-24 at 18:39 +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.
>
> Signed-off-by: huxiaoying <huxiaoying@kylinos.cn>
The previous behavior seems faulty. Let's add a Fixes: tag.
FWIW:
Reviewed-by: Rong Zhang <i@rong.moe>
Thanks,
Rong
> ---
> 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);
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-25 14:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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
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®