Re: [PATCH v9 14/16] platform/x86: lenovo-wmi-other: Add WMI battery charge limiting

From: Rong Zhang

Date: Fri Apr 24 2026 - 10:20:53 EST


Hi Nícolas,

On Fri, 2026-04-24 at 08:50 -0400, Nícolas F. R. A. Prado wrote:
> On Sat, 2026-04-11 at 16:23 +0000, Derek J. Clark wrote:
> > Add charge-type power supply extension for devices that support WMI
> > based
> > charge enable/disable.
> >
> > Lenovo Legion devices that implement WMI function and capdata ID
> > 0x03010001 in their BIOS are able to enable or disable charging at
> > 80%
> > through the lenovo-wmi-other interface. Add a charge_type power
> > supply
> > extension to expose this capability to the sysfs.
>
> Hi,
>
> this is not the right uAPI to expose this capability.
>
> If you check the ABI description for
> /sys/class/power_supply/<supply_name>/charge_type [1], it mentions
> "rate" and if you check the corresponding enum definition [2] it
> mentions "speed", so the charge_type uAPI is very clearly meant to
> expose the the charge rate/speed/current currently configured, with
> Long Life specifically meaning a reduced charge rate, rather than
> reduced charge capacity.
>
> The uAPI you're looking for here is
> /sys/class/power_supply/<supply_name>/charge_control_end_threshold [3],
> which very explicitly exposes the charge threshold in percentage. You
> can then accept only 100 or 80 as valid values and configure your
> hardware accordingly. 
>

I am not sure if it's viable to do so.

The charge threshold may vary among different devices. For ideapad-
laptop devices, there are at least two variants: 60 and 80, without any
programmatic way to query the threshold. I guess that's why ideapad-
laptop "misused" the uAPI.

Since some devices actually support both ideapad ACPI methods and
WMI_OTHER methods, I doubt if the WMI_OTHER charge threshold also varies
among different devices in a very similar way.

Thanks,
Rong

> Unfortunately there's currently no way for
> userspace to know that these are the only valid values (which is
> something that I want to look into implementing soon), it can only read
> back to see if what it wrote was accepted, but it's still the best uAPI
> for this.
>
> I see that there have been 2 commits merged last year that make the
> exact same misuse of the uAPI, which probably contributed to the
> confusion here, but the ship has sailed for those.
>
> [1]
> https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-power-supply-supply-name-charge-type
> [2]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/power_supply.h?h=v7.0&id=028ef9c96e96197026887c0f092424679298aae8#n45
> [3]
> https://docs.kernel.org/admin-guide/abi-testing.html#abi-sys-class-power-supply-supply-name-charge-control-end-threshold
> [4]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=de2884c6cdd3d133704ce37393590dd1c761500c
> [5]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=da8f2708f9b69707f4efeb432a18395e46b4666f
>
> Thanks,
> Nícolas