mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nícolas F. R. A. Prado" <nfraprado@collabora.com>
To: "Derek J. Clark" <derekjohn.clark@gmail.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Hans de Goede" <hansg@kernel.org>
Cc: Mark Pearson <mpearson-lenovo@squebb.ca>,
	Armin Wolf <W_Armin@gmx.de>,  Jonathan Corbet <corbet@lwn.net>,
	Rong Zhang <i@rong.moe>, Kurt Borja <kuurtb@gmail.com>,
	 platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 14/16] platform/x86: lenovo-wmi-other: Add WMI battery charge limiting
Date: Fri, 24 Apr 2026 08:50:53 -0400	[thread overview]
Message-ID: <09d21c9cee8af49fa1d5b568358db0c347668ee9.camel@collabora.com> (raw)
In-Reply-To: <20260411162334.25682-15-derekjohn.clark@gmail.com>

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. 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

  reply	other threads:[~2026-04-24 12:51 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 16:23 [PATCH v9 00/16] platform-x86: lenovo-wmi: Add fixes and enhancement Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 01/16] platform/x86: lenovo-wmi-helpers: Fix memory leak in lwmi_dev_evaluate_int() Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 02/16] platform/x86: lenovo-wmi-other: Balance IDA id allocation and free Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 03/16] platform/x86: lenovo-wmi-other: Balance component bind and unbind Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 04/16] platform/x86: lenovo-wmi-other: Zero initialize WMI arguments Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 05/16] platform/x86: lenovo-wmi-other: Fix tunable_attr_01 struct members Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 06/16] platform/x86: lenovo-wmi-other: Limit adding attributes to supported devices Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 07/16] platform/x86: lenovo: Decouple lenovo-wmi-gamezone and lenovo-wmi-other Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 08/16] platform/x86: lenovo-wmi-helpers: Move gamezone enums to wmi-helpers Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 09/16] platform/x86: lenovo-wmi-other: Move LWMI_FAN_DIV Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 10/16] platform/x86: lenovo-wmi-other: Add lwmi_attr_id() function Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 11/16] platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 12/16] platform/x86: lenovo-wmi-other: Add GPU " Derek J. Clark
2026-04-11 16:40   ` Rong Zhang
2026-04-11 16:50     ` Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 13/16] platform/x86: lenovo-wmi-other: Rename LWMI_OM_FW_ATTR_BASE_PATH Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 14/16] platform/x86: lenovo-wmi-other: Add WMI battery charge limiting Derek J. Clark
2026-04-24 12:50   ` Nícolas F. R. A. Prado [this message]
2026-04-24 14:13     ` Rong Zhang
2026-05-11 18:48     ` Hans de Goede
2026-05-11 19:48       ` Derek J. Clark
2026-05-11 20:10         ` Rong Zhang
2026-05-12  9:40         ` Hans de Goede
2026-04-11 16:23 ` [PATCH v9 15/16] platform/x86: lenovo-wmi-helpers: Add helper for creating per-device debugfs dir Derek J. Clark
2026-04-11 16:23 ` [PATCH v9 16/16] platform/x86: lenovo-wmi-capdata: Add debugfs file for dumping capdata Derek J. Clark

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=09d21c9cee8af49fa1d5b568358db0c347668ee9.camel@collabora.com \
    --to=nfraprado@collabora.com \
    --cc=W_Armin@gmx.de \
    --cc=corbet@lwn.net \
    --cc=derekjohn.clark@gmail.com \
    --cc=hansg@kernel.org \
    --cc=i@rong.moe \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=kuurtb@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    /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®