From: Armin Wolf <W_Armin@gmx.de>
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, bifangknt@qq.com,
nicokessler@icloud.com, sre@kernel.org, linux-pm@vger.kernel.org,
wse@tuxedocomputers.com
Subject: [PATCH 4/9] platform/x86: uniwill-laptop: Expose battery health and cycle count on all devices
Date: Tue, 10 Nov 2026 01:06:46 +0100 [thread overview]
Message-ID: <20261110001725.851443-5-W_Armin@gmx.de> (raw)
In-Reply-To: <20261110001725.851443-1-W_Armin@gmx.de>
We can assume that all passive battery properties (health and cycle
count) are available on all devices if the underlying EC interface
is supported. Rework the battery extension initialization code to
always register a power supply extension with at least those two
properties.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/platform/x86/uniwill/uniwill-acpi.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
index 1958a1bfc880..66770f939c83 100644
--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
@@ -2171,6 +2171,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
u32 charge_types = BIT(POWER_SUPPLY_CHARGE_TYPE_TRICKLE) |
BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) |
BIT(POWER_SUPPLY_CHARGE_TYPE_LONGLIFE);
+ int i = 0;
int ret;
if (uniwill_device_supports(data, UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT)) {
@@ -2195,7 +2196,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
return ret;
}
- data->extension_props[0] = POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD;
+ data->extension_props[i++] = POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD;
} else if (uniwill_device_supports(data, UNIWILL_FEATURE_BATTERY_CHARGE_MODES)) {
ret = devm_mutex_init(data->dev, &data->charge_type_lock);
if (ret < 0)
@@ -2205,28 +2206,26 @@ static int uniwill_battery_init(struct uniwill_data *data)
if (ret < 0)
return ret;
- data->extension_props[0] = POWER_SUPPLY_PROP_CHARGE_TYPES;
+ data->extension_props[i++] = POWER_SUPPLY_PROP_CHARGE_TYPES;
data->standard_extension.charge_types = charge_types;
data->cycle_count_extension.charge_types = charge_types;
- } else {
- return 0;
}
- data->extension_props[1] = POWER_SUPPLY_PROP_HEALTH;
+ data->extension_props[i++] = POWER_SUPPLY_PROP_HEALTH;
/* Needs to come last */
- data->extension_props[2] = POWER_SUPPLY_PROP_CYCLE_COUNT;
+ data->extension_props[i++] = POWER_SUPPLY_PROP_CYCLE_COUNT;
data->standard_extension.name = DRIVER_NAME;
data->standard_extension.properties = data->extension_props;
/* POWER_SUPPLY_PROP_CYCLE_COUNT is usually already provided by the ACPI battery */
- data->standard_extension.num_properties = ARRAY_SIZE(data->extension_props) - 1;
+ data->standard_extension.num_properties = i - 1;
data->standard_extension.get_property = uniwill_get_property;
data->standard_extension.set_property = uniwill_set_property;
data->standard_extension.property_is_writeable = uniwill_property_is_writeable;
data->cycle_count_extension.name = DRIVER_NAME;
data->cycle_count_extension.properties = data->extension_props;
- data->cycle_count_extension.num_properties = ARRAY_SIZE(data->extension_props);
+ data->cycle_count_extension.num_properties = i;
data->cycle_count_extension.get_property = uniwill_get_property;
data->cycle_count_extension.set_property = uniwill_set_property;
data->cycle_count_extension.property_is_writeable = uniwill_property_is_writeable;
@@ -2251,11 +2250,6 @@ static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action
switch (action) {
case UNIWILL_OSD_BATTERY_ALERT:
- if (!uniwill_device_supports_any(data,
- UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT |
- UNIWILL_FEATURE_BATTERY_CHARGE_MODES))
- return NOTIFY_DONE;
-
mutex_lock(&data->battery_lock);
list_for_each_entry(entry, &data->batteries, head) {
power_supply_changed(entry->battery);
--
2.56.0
next prev parent reply other threads:[~2026-11-10 0:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 0:06 [PATCH 0/9] platform/x86: uniwill-laptop: Complete battery support Armin Wolf
2026-11-10 0:06 ` [PATCH 1/9] power: supply: core: Add power_supply_has_property_direct() Armin Wolf
2026-11-10 0:06 ` [PATCH 2/9] power: supply: Enable struct power_supply_ext to be construct dynamically Armin Wolf
2026-11-10 0:06 ` [PATCH 3/9] platform/x86: uniwill-laptop: Report battery cycle count Armin Wolf
2026-11-10 0:06 ` Armin Wolf [this message]
2026-11-10 0:06 ` [PATCH 5/9] platform/x86: uniwill-laptop: Expose raw battery capacity to userspace Armin Wolf
2026-11-10 0:06 ` [PATCH 6/9] platform/x86: uniwill-laptop: Mark sysfs attributes as const Armin Wolf
2026-11-10 0:06 ` [PATCH 7/9] platform/x86: uniwill-laptop: Add support for MECHREVO Yilong15Pro Armin Wolf
2026-11-10 0:06 ` [PATCH 8/9] platform/x86: uniwill-laptop: Add MECHREVO JIAOLONG Series-X6xR55xK Armin Wolf
2026-11-10 0:06 ` [PATCH 9/9] platform/x86: uniwill-laptop: Add support for XMG EVO 14 (E25) Armin Wolf
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=20261110001725.851443-5-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=bifangknt@qq.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nicokessler@icloud.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sre@kernel.org \
--cc=wse@tuxedocomputers.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®