* [PATCH v3 0/3] hwmon: (applesmc) add charge_control_end_threshold support
@ 2026-09-30 22:26 Jordan Brough
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jordan Brough @ 2026-09-30 22:26 UTC (permalink / raw)
To: Rafael J. Wysocki, Guenter Roeck, Henrik Rydberg
Cc: Jordan Brough, chrome-platform, ibm-acpi-devel, linux-acpi,
linux-hwmon, linux-kernel, linux-pm, platform-driver-x86
This series adds charge_control_end_threshold to the applesmc driver for
Intel MacBooks, using the power_supply extension API.
Some of these machines have an SBS battery (drivers/acpi/sbs.c), which,
unlike battery.c, has no battery hook mechanism. Patch 2 moves the hook code
into a helper that both drivers use, and patch 3 adds the applesmc support.
Patch 1 is the acpi_ prefix rename of the existing hook functions that Rafael
asked for; it is separate because it touches 18 callers in other subsystems.
The series is based on linux-pm's bleeding-edge branch (4c18627a1dfb). Patch
3 depends on patch 2, so the series would need to go in through the ACPI
tree with an ack from the hwmon side, or I can resend patch 3 once patches 1
and 2 are in, whichever is easier.
Changes in v3 (thanks to Rafael for the review):
- Patch 1 is new: acpi_ prefix for the exported hook functions, with their
callers updated.
- Patch 2:
- Renamed battery_hook.c to battery_hooks.c, built only when ACPI_BATTERY
or ACPI_SBS is, through a hidden ACPI_BATTERY_HOOKS symbol that both
select.
- Renamed the struct and the new functions as suggested, exported the new
functions in the ACPI_BATTERY_HOOKS namespace, used mutex guards and
updated the file header.
- battery_hook_exit() is gone, so hooks now stay registered across a
reload of battery.ko or sbs.ko.
- Patch 3:
- BFCL is only written when the SMC has the key, and the BCLM write is read
back, at the suggestion of Michal Szpakowski, whose MacBookPro13,1 has no
BFCL.
- No BFCL margin at a limit of 100.
- The lower limit of 20 is conservative: 20 works and 10 is not accepted
on the hardware I tried, but I did not find the exact floor. I am happy
to change it.
- Dropped the applesmc_hooked_battery tracking and the mutex in
applesmc_bat_get_property().
- The hook is only registered when CONFIG_ACPI_BATTERY_HOOKS is reachable.
Testing:
- MacBookAir6,2 (SBS battery), on an earlier revision: limits from 20 to 100
match the SMC keys, charging stops at the limit, repeated module reloads
caused no errors, and the threshold was unchanged after a suspend/resume.
- MacBookPro13,1 (SBS battery, no BFCL), by Michal Szpakowski, before the
acpi_ rename: valid limits read back exactly, invalid ones are rejected,
applesmc reload and an acpi-sbs unbind/rebind re-attach the attribute, and
charging stops at the limit.
- Lenovo ideapad FLEX 4-1480 (Control Method battery, ideapad_laptop), on
Fedora's 7.2.7 kernel with the series applied on top (a rebase of the
patches, not this exact tree): the ideapad_laptop hook registers and its
charge_types attribute appears on BAT1, charge_types can be read and
written back unchanged, 25 battery unbind/bind cycles re-attach it each
time, and unloading and reloading ideapad_laptop removes and re-adds it.
There were no warnings in dmesg. That kernel did not have lockdep
enabled.
- Built and linked with ACPI_BATTERY and ACPI_SBS as y/m/n and applesmc as
y/m, and an x86 allmodconfig build of the touched files with W=1 shows no
warnings; each patch builds on its own.
- Applies with git am on linux-pm bleeding-edge, and with git am --3way on
hwmon-next.
Link: https://lore.kernel.org/r/20260918175052.85461-1-jordan@brough.org [v2]
Link: https://lore.kernel.org/r/20260913231410.416922-1-jordan@brough.org [v1]
Jordan Brough (3):
ACPI: battery: add acpi_ prefix to the battery hook API
ACPI: battery: add unified battery hook mechanism for ACPI and SBS
batteries
hwmon: (applesmc) add charge_control_end_threshold support
drivers/acpi/Kconfig | 5 +
drivers/acpi/Makefile | 1 +
drivers/acpi/battery.c | 166 +------------------
drivers/acpi/battery_hooks.c | 159 ++++++++++++++++++
drivers/acpi/sbs.c | 8 +-
drivers/hwmon/Kconfig | 1 +
drivers/hwmon/applesmc.c | 146 ++++++++++++++++
drivers/platform/x86/asus-wmi.c | 4 +-
drivers/platform/x86/ayaneo-ec.c | 2 +-
drivers/platform/x86/dell/dell-laptop.c | 4 +-
drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
drivers/platform/x86/fujitsu-laptop.c | 4 +-
drivers/platform/x86/huawei-wmi.c | 4 +-
drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +-
drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +-
drivers/platform/x86/lenovo/wmi-other.c | 4 +-
drivers/platform/x86/lg-laptop.c | 4 +-
drivers/platform/x86/msi-ec.c | 4 +-
drivers/platform/x86/oxpec.c | 2 +-
drivers/platform/x86/samsung-galaxybook.c | 3 +-
drivers/platform/x86/samsung-laptop.c | 4 +-
drivers/platform/x86/system76_acpi.c | 4 +-
drivers/platform/x86/toshiba_acpi.c | 4 +-
drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
drivers/power/supply/cros_charge-control.c | 2 +-
include/acpi/battery.h | 16 +-
26 files changed, 367 insertions(+), 196 deletions(-)
create mode 100644 drivers/acpi/battery_hooks.c
base-commit: 4c18627a1dfbfe537580f831e60218644c94ce12
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API
2026-09-30 22:26 [PATCH v3 0/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
@ 2026-09-30 22:26 ` Jordan Brough
2026-09-30 23:19 ` Armin Wolf
` (3 more replies)
2026-09-30 22:26 ` [PATCH v3 2/3] ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries Jordan Brough
2026-09-30 22:26 ` [PATCH v3 3/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
2 siblings, 4 replies; 8+ messages in thread
From: Jordan Brough @ 2026-09-30 22:26 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Corentin Chary, Luke D. Jones,
Denis Benato, Hans de Goede, Ilpo Järvinen,
Antheas Kapenekakis, Matthew Garrett, Pali Rohár,
Armin Wolf, Jonathan Woithe, Mark Pearson, Derek J. Clark,
Ike Panhc, Henrique de Moraes Holschuh, Matan Ziv-Av,
Nikita Kravets, Joaquín Ignacio Aramendía,
Joshua Grisham, Jeremy Soller, System76 Product Development,
Azael Avalos, Thomas Weißschuh, Benson Leung, Guenter Roeck,
Sebastian Reichel
Cc: Jordan Brough, linux-acpi, linux-kernel, platform-driver-x86,
ibm-acpi-devel, chrome-platform, linux-pm
Rename battery_hook_register(), battery_hook_unregister() and
devm_battery_hook_register() to acpi_battery_hook_register(),
acpi_battery_hook_unregister() and devm_acpi_battery_hook_register(), so
that the exported ACPI battery hook API has a consistent namespace, and
update all in-tree callers.
No functional change.
Signed-off-by: Jordan Brough <jordan@brough.org>
---
drivers/acpi/battery.c | 30 ++++++++++----------
drivers/platform/x86/asus-wmi.c | 4 +--
drivers/platform/x86/ayaneo-ec.c | 2 +-
drivers/platform/x86/dell/dell-laptop.c | 4 +--
drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
drivers/platform/x86/fujitsu-laptop.c | 4 +--
drivers/platform/x86/huawei-wmi.c | 4 +--
drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +--
drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +--
drivers/platform/x86/lenovo/wmi-other.c | 4 +--
drivers/platform/x86/lg-laptop.c | 4 +--
drivers/platform/x86/msi-ec.c | 4 +--
drivers/platform/x86/oxpec.c | 2 +-
drivers/platform/x86/samsung-galaxybook.c | 3 +-
drivers/platform/x86/samsung-laptop.c | 4 +--
drivers/platform/x86/system76_acpi.c | 4 +--
drivers/platform/x86/toshiba_acpi.c | 4 +--
drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
drivers/power/supply/cros_charge-control.c | 2 +-
include/acpi/battery.h | 7 +++--
20 files changed, 50 insertions(+), 48 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 8599949f8786..306bb2088ca6 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -821,7 +821,7 @@ static LIST_HEAD(acpi_battery_list);
static LIST_HEAD(battery_hook_list);
static DEFINE_MUTEX(hook_mutex);
-static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
+static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
{
struct acpi_battery *battery;
@@ -838,7 +838,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
pr_info("hook unregistered: %s\n", hook->name);
}
-void battery_hook_unregister(struct acpi_battery_hook *hook)
+void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
{
mutex_lock(&hook_mutex);
/*
@@ -847,13 +847,13 @@ void battery_hook_unregister(struct acpi_battery_hook *hook)
* adding a new battery.
*/
if (!list_empty(&hook->list))
- battery_hook_unregister_unlocked(hook);
+ acpi_battery_hook_unregister_unlocked(hook);
mutex_unlock(&hook_mutex);
}
-EXPORT_SYMBOL_GPL(battery_hook_unregister);
+EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
-void battery_hook_register(struct acpi_battery_hook *hook)
+void acpi_battery_hook_register(struct acpi_battery_hook *hook)
{
struct acpi_battery *battery;
@@ -874,7 +874,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
* hooks.
*/
pr_err("hook failed to load: %s", hook->name);
- battery_hook_unregister_unlocked(hook);
+ acpi_battery_hook_unregister_unlocked(hook);
goto end;
}
@@ -884,22 +884,22 @@ void battery_hook_register(struct acpi_battery_hook *hook)
end:
mutex_unlock(&hook_mutex);
}
-EXPORT_SYMBOL_GPL(battery_hook_register);
+EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
-static void devm_battery_hook_unregister(void *data)
+static void devm_acpi_battery_hook_unregister(void *data)
{
struct acpi_battery_hook *hook = data;
- battery_hook_unregister(hook);
+ acpi_battery_hook_unregister(hook);
}
-int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
+int devm_acpi_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
{
- battery_hook_register(hook);
+ acpi_battery_hook_register(hook);
- return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
+ return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
}
-EXPORT_SYMBOL_GPL(devm_battery_hook_register);
+EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
/*
* This function gets called right after the battery sysfs
@@ -928,7 +928,7 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
*/
pr_err("error in hook, unloading: %s",
hook_node->name);
- battery_hook_unregister_unlocked(hook_node);
+ acpi_battery_hook_unregister_unlocked(hook_node);
}
}
mutex_unlock(&hook_mutex);
@@ -961,7 +961,7 @@ static void __exit battery_hook_exit(void)
* need to remove the hooks.
*/
list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
- battery_hook_unregister(hook);
+ acpi_battery_hook_unregister(hook);
}
mutex_destroy(&hook_mutex);
}
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index a65090429ca7..c274f456863c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1681,14 +1681,14 @@ static void asus_wmi_battery_init(struct asus_wmi *asus)
asus->battery_rsoc_available = false;
if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) {
asus->battery_rsoc_available = true;
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
}
}
static void asus_wmi_battery_exit(struct asus_wmi *asus)
{
if (asus->battery_rsoc_available)
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
}
/* LEDs ***********************************************************************/
diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
index 41a24e091248..3ba87bd16c9a 100644
--- a/drivers/platform/x86/ayaneo-ec.c
+++ b/drivers/platform/x86/ayaneo-ec.c
@@ -493,7 +493,7 @@ static int ayaneo_ec_probe(struct platform_device *pdev)
data->battery_hook.add_battery = ayaneo_add_battery;
data->battery_hook.remove_battery = ayaneo_remove_battery;
data->battery_hook.name = "Ayaneo Battery";
- ret = devm_battery_hook_register(&pdev->dev, &data->battery_hook);
+ ret = devm_acpi_battery_hook_register(&pdev->dev, &data->battery_hook);
if (ret)
return ret;
}
diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
index 89e85c7f7132..cad2bd06f28a 100644
--- a/drivers/platform/x86/dell/dell-laptop.c
+++ b/drivers/platform/x86/dell/dell-laptop.c
@@ -2446,13 +2446,13 @@ static void __init dell_battery_init(struct device *dev)
battery_supported_modes = battery_get_supported_modes();
if (battery_supported_modes != 0)
- battery_hook_register(&dell_battery_hook);
+ acpi_battery_hook_register(&dell_battery_hook);
}
static void dell_battery_exit(void)
{
if (battery_supported_modes != 0)
- battery_hook_unregister(&dell_battery_hook);
+ acpi_battery_hook_unregister(&dell_battery_hook);
}
static int __init dell_init(void)
diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
index f8903ced461b..6f0504d7519e 100644
--- a/drivers/platform/x86/dell/dell-wmi-ddv.c
+++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
@@ -972,7 +972,7 @@ static int dell_wmi_ddv_battery_add(struct dell_wmi_ddv_data *data)
data->eppid_attr.attr.mode = 0444;
data->eppid_attr.show = eppid_show;
- return devm_battery_hook_register(&data->wdev->dev, &data->hook);
+ return devm_acpi_battery_hook_register(&data->wdev->dev, &data->hook);
}
static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum dell_ddv_method method)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index ea543deef68f..96e74c4fdb29 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -267,7 +267,7 @@ static int fujitsu_battery_charge_control_add(struct device *dev)
return -ENODEV;
priv->charge_control_supported = true;
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
return 0;
}
@@ -277,7 +277,7 @@ static void fujitsu_battery_charge_control_remove(struct device *dev)
struct fujitsu_laptop *priv = dev_get_drvdata(dev);
if (priv->charge_control_supported)
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
}
/* Hardware access for LCD brightness control */
diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
index d6aaf14d66a5..8cc0e900e984 100644
--- a/drivers/platform/x86/huawei-wmi.c
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -512,7 +512,7 @@ static void huawei_wmi_battery_setup(struct device *dev)
return;
}
- battery_hook_register(&huawei_wmi_battery_hook);
+ acpi_battery_hook_register(&huawei_wmi_battery_hook);
device_create_file(dev, &dev_attr_charge_control_thresholds);
}
@@ -521,7 +521,7 @@ static void huawei_wmi_battery_exit(struct device *dev)
struct huawei_wmi *huawei = dev_get_drvdata(dev);
if (huawei->battery_available) {
- battery_hook_unregister(&huawei_wmi_battery_hook);
+ acpi_battery_hook_unregister(&huawei_wmi_battery_hook);
device_remove_file(dev, &dev_attr_charge_control_thresholds);
}
}
diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
index 8213524504ee..1d90d4591641 100644
--- a/drivers/platform/x86/lenovo/ideapad-laptop.c
+++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
@@ -2197,8 +2197,8 @@ static int ideapad_check_features(struct ideapad_private *priv)
priv->battery_hook.remove_battery = ideapad_battery_remove;
priv->battery_hook.name = "Ideapad Battery Extension";
- err = devm_battery_hook_register(&priv->platform_device->dev,
- &priv->battery_hook);
+ err = devm_acpi_battery_hook_register(&priv->platform_device->dev,
+ &priv->battery_hook);
if (err)
return err;
}
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 1661f070c571..eb5ad18855db 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -10021,13 +10021,13 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
battery_quirk_table,
ARRAY_SIZE(battery_quirk_table));
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
return 0;
}
static void tpacpi_battery_exit(void)
{
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
}
static struct ibm_struct battery_driver_data = {
diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
index fbb32bf404f2..0450634ac1dd 100644
--- a/drivers/platform/x86/lenovo/wmi-other.c
+++ b/drivers/platform/x86/lenovo/wmi-other.c
@@ -946,7 +946,7 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
priv->battery_hook.name = "Lenovo WMI Other Battery Extension";
priv->bh_registered = true;
- battery_hook_register(&priv->battery_hook);
+ acpi_battery_hook_register(&priv->battery_hook);
}
/**
@@ -960,7 +960,7 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
if (!priv->bh_registered)
return;
- battery_hook_unregister(&priv->battery_hook);
+ acpi_battery_hook_unregister(&priv->battery_hook);
priv->bh_registered = false;
}
diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
index 36ad1e269443..e788671307c4 100644
--- a/drivers/platform/x86/lg-laptop.c
+++ b/drivers/platform/x86/lg-laptop.c
@@ -1053,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
if (ret)
goto out_platform_device;
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
return 0;
@@ -1068,7 +1068,7 @@ static void acpi_remove(struct platform_device *pdev)
{
sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group);
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
platform_device_unregister(pf_device);
pf_device = NULL;
platform_driver_unregister(&pf_driver);
diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
index 566dfc73cb67..cb30a1d5b546 100644
--- a/drivers/platform/x86/msi-ec.c
+++ b/drivers/platform/x86/msi-ec.c
@@ -1428,13 +1428,13 @@ static int __init msi_ec_init(void)
if (result < 0)
return result;
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
return 0;
}
static void __exit msi_ec_exit(void)
{
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
}
MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c
index 34bb17fca148..318f194e72b5 100644
--- a/drivers/platform/x86/oxpec.c
+++ b/drivers/platform/x86/oxpec.c
@@ -956,7 +956,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
return PTR_ERR(hwdev);
if (oxp_psy_ext_supported()) {
- ret = devm_battery_hook_register(dev, &battery_hook);
+ ret = devm_acpi_battery_hook_register(dev, &battery_hook);
if (ret)
return ret;
}
diff --git a/drivers/platform/x86/samsung-galaxybook.c b/drivers/platform/x86/samsung-galaxybook.c
index 99f72b204a51..a4f7dbb76214 100644
--- a/drivers/platform/x86/samsung-galaxybook.c
+++ b/drivers/platform/x86/samsung-galaxybook.c
@@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct samsung_galaxybook *galaxybo
galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
galaxybook->battery_hook.name = "Samsung Galaxy Book Battery Extension";
- return devm_battery_hook_register(&galaxybook->platform->dev, &galaxybook->battery_hook);
+ return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
+ &galaxybook->battery_hook);
}
/*
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index 710f3d5bf84c..43fa1dc2773c 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -1142,8 +1142,8 @@ static int __init samsung_battery_hook_init(struct samsung_laptop *samsung)
samsung->battery_hook.add_battery = samsung_battery_add;
samsung->battery_hook.remove_battery = samsung_battery_remove;
samsung->battery_hook.name = "Samsung Battery Extension";
- retval = devm_battery_hook_register(&samsung->platform_device->dev,
- &samsung->battery_hook);
+ retval = devm_acpi_battery_hook_register(&samsung->platform_device->dev,
+ &samsung->battery_hook);
}
return retval;
diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
index dd7b1b07c316..33968b61f0b2 100644
--- a/drivers/platform/x86/system76_acpi.c
+++ b/drivers/platform/x86/system76_acpi.c
@@ -288,12 +288,12 @@ static struct acpi_battery_hook system76_battery_hook = {
static void system76_battery_init(void)
{
- battery_hook_register(&system76_battery_hook);
+ acpi_battery_hook_register(&system76_battery_hook);
}
static void system76_battery_exit(void)
{
- battery_hook_unregister(&system76_battery_hook);
+ acpi_battery_hook_unregister(&system76_battery_hook);
}
// Get the airplane mode LED brightness
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index a0b8060836d0..4cc879bc267a 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -3301,7 +3301,7 @@ static void toshiba_acpi_remove(struct platform_device *pdev)
}
if (dev->battery_charge_mode_supported)
- battery_hook_unregister(&battery_hook);
+ acpi_battery_hook_unregister(&battery_hook);
if (toshiba_acpi)
toshiba_acpi = NULL;
@@ -3566,7 +3566,7 @@ static int toshiba_acpi_probe(struct platform_device *pdev)
* set, this must be done after toshiba_acpi is assigned.
*/
if (dev->battery_charge_mode_supported)
- battery_hook_register(&battery_hook);
+ acpi_battery_hook_register(&battery_hook);
return 0;
diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
index 7a2eeaec4c96..d76695c2c765 100644
--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
@@ -2165,7 +2165,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
data->hook.add_battery = uniwill_add_battery;
data->hook.remove_battery = uniwill_remove_battery;
- return devm_battery_hook_register(data->dev, &data->hook);
+ return devm_acpi_battery_hook_register(data->dev, &data->hook);
}
static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action, void *dummy)
diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
index e0f168624807..1901bbcffd73 100644
--- a/drivers/power/supply/cros_charge-control.c
+++ b/drivers/power/supply/cros_charge-control.c
@@ -315,7 +315,7 @@ static int cros_chctl_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- return devm_battery_hook_register(dev, &priv->battery_hook);
+ return devm_acpi_battery_hook_register(dev, &priv->battery_hook);
}
static const struct platform_device_id cros_chctl_id[] = {
diff --git a/include/acpi/battery.h b/include/acpi/battery.h
index c93f16dfb944..08c7e37996bf 100644
--- a/include/acpi/battery.h
+++ b/include/acpi/battery.h
@@ -18,8 +18,9 @@ struct acpi_battery_hook {
struct list_head list;
};
-void battery_hook_register(struct acpi_battery_hook *hook);
-void battery_hook_unregister(struct acpi_battery_hook *hook);
-int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook);
+void acpi_battery_hook_register(struct acpi_battery_hook *hook);
+void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
+int devm_acpi_battery_hook_register(struct device *dev,
+ struct acpi_battery_hook *hook);
#endif
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/3] ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries
2026-09-30 22:26 [PATCH v3 0/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
@ 2026-09-30 22:26 ` Jordan Brough
2026-09-30 22:26 ` [PATCH v3 3/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
2 siblings, 0 replies; 8+ messages in thread
From: Jordan Brough @ 2026-09-30 22:26 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown
Cc: Jordan Brough, Thomas Weißschuh, linux-kernel, linux-acpi
The battery hook API only works with ACPI Control Method batteries
(battery.c). Machines with a Smart Battery System battery (sbs.c) have no
equivalent, so drivers cannot attach extra power_supply properties to them.
Move the hook list and registration code out of battery.c into a new
battery_hooks.c that both battery.c and sbs.c use, through
acpi_battery_add_hooks() and acpi_battery_remove_hooks(), which are
exported in the ACPI_BATTERY_HOOKS namespace. The exported hook functions
are unchanged.
The new file is built only when ACPI_BATTERY or ACPI_SBS is, through a
hidden ACPI_BATTERY_HOOKS symbol that they select. Since the hook lists
now live there, registered hooks stay registered when battery.ko or
sbs.ko is reloaded, and battery_hook_exit() is no longer needed.
Suggested-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Jordan Brough <jordan@brough.org>
---
drivers/acpi/Kconfig | 5 ++
drivers/acpi/Makefile | 1 +
drivers/acpi/battery.c | 166 +----------------------------------
drivers/acpi/battery_hooks.c | 159 +++++++++++++++++++++++++++++++++
drivers/acpi/sbs.c | 8 +-
include/acpi/battery.h | 9 ++
6 files changed, 185 insertions(+), 163 deletions(-)
create mode 100644 drivers/acpi/battery_hooks.c
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f165d14cf61a..d0278f13e96f 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -171,8 +171,12 @@ config ACPI_AC
To compile this driver as a module, choose M here:
the module will be called ac.
+config ACPI_BATTERY_HOOKS
+ tristate
+
config ACPI_BATTERY
tristate "Battery"
+ select ACPI_BATTERY_HOOKS
select POWER_SUPPLY
default y
help
@@ -445,6 +449,7 @@ config ACPI_HOTPLUG_IOAPIC
config ACPI_SBS
tristate "Smart Battery System"
depends on X86 && ACPI_EC
+ select ACPI_BATTERY_HOOKS
select POWER_SUPPLY
help
This driver supports the Smart Battery System, another
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d1b0affb844f..eb744dc81d3f 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -97,6 +97,7 @@ obj-$(CONFIG_ACPI_NHLT) += nhlt.o
obj-$(CONFIG_ACPI_NUMA) += numa/
obj-$(CONFIG_ACPI) += acpi_memhotplug.o
obj-$(CONFIG_ACPI_HOTPLUG_IOAPIC) += ioapic.o
+obj-$(CONFIG_ACPI_BATTERY_HOOKS) += battery_hooks.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_SBS) += sbshc.o
obj-$(CONFIG_ACPI_SBS) += sbs.o
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 306bb2088ca6..0d74f998eae6 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -54,6 +54,7 @@ MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
MODULE_DESCRIPTION("ACPI Battery Driver");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("ACPI_BATTERY_HOOKS");
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
@@ -105,7 +106,7 @@ struct acpi_battery {
struct kfifo acpi_notif_fifo;
struct delayed_work acpi_notif_dwork;
struct notifier_block pm_nb;
- struct list_head list;
+ struct acpi_battery_hooks_list_entry hooks_list_entry;
unsigned long flags;
struct mutex property_lock; /* Protects properties below. */
@@ -808,164 +809,6 @@ static struct attribute *acpi_battery_attrs[] = {
};
ATTRIBUTE_GROUPS(acpi_battery);
-/*
- * The Battery Hooking API
- *
- * This API is used inside other drivers that need to expose
- * platform-specific behaviour within the generic driver in a
- * generic way.
- *
- */
-
-static LIST_HEAD(acpi_battery_list);
-static LIST_HEAD(battery_hook_list);
-static DEFINE_MUTEX(hook_mutex);
-
-static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
-{
- struct acpi_battery *battery;
-
- /*
- * In order to remove a hook, we first need to
- * de-register all the batteries that are registered.
- */
- list_for_each_entry(battery, &acpi_battery_list, list) {
- if (!hook->remove_battery(battery->bat, hook))
- power_supply_changed(battery->bat);
- }
- list_del_init(&hook->list);
-
- pr_info("hook unregistered: %s\n", hook->name);
-}
-
-void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
-{
- mutex_lock(&hook_mutex);
- /*
- * Ignore already unregistered battery hooks. This might happen
- * if a battery hook was previously unloaded due to an error when
- * adding a new battery.
- */
- if (!list_empty(&hook->list))
- acpi_battery_hook_unregister_unlocked(hook);
-
- mutex_unlock(&hook_mutex);
-}
-EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
-
-void acpi_battery_hook_register(struct acpi_battery_hook *hook)
-{
- struct acpi_battery *battery;
-
- mutex_lock(&hook_mutex);
- list_add(&hook->list, &battery_hook_list);
- /*
- * Now that the driver is registered, we need
- * to notify the hook that a battery is available
- * for each battery, so that the driver may add
- * its attributes.
- */
- list_for_each_entry(battery, &acpi_battery_list, list) {
- if (hook->add_battery(battery->bat, hook)) {
- /*
- * If a add-battery returns non-zero,
- * the registration of the hook has failed,
- * and we will not add it to the list of loaded
- * hooks.
- */
- pr_err("hook failed to load: %s", hook->name);
- acpi_battery_hook_unregister_unlocked(hook);
- goto end;
- }
-
- power_supply_changed(battery->bat);
- }
- pr_info("new hook: %s\n", hook->name);
-end:
- mutex_unlock(&hook_mutex);
-}
-EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
-
-static void devm_acpi_battery_hook_unregister(void *data)
-{
- struct acpi_battery_hook *hook = data;
-
- acpi_battery_hook_unregister(hook);
-}
-
-int devm_acpi_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
-{
- acpi_battery_hook_register(hook);
-
- return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
-}
-EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
-
-/*
- * This function gets called right after the battery sysfs
- * attributes have been added, so that the drivers that
- * define custom sysfs attributes can add their own.
- */
-static void battery_hook_add_battery(struct acpi_battery *battery)
-{
- struct acpi_battery_hook *hook_node, *tmp;
-
- mutex_lock(&hook_mutex);
- INIT_LIST_HEAD(&battery->list);
- list_add(&battery->list, &acpi_battery_list);
- /*
- * Since we added a new battery to the list, we need to
- * iterate over the hooks and call add_battery for each
- * hook that was registered. This usually happens
- * when a battery gets hotplugged or initialized
- * during the battery module initialization.
- */
- list_for_each_entry_safe(hook_node, tmp, &battery_hook_list, list) {
- if (hook_node->add_battery(battery->bat, hook_node)) {
- /*
- * The notification of the hook has failed, to
- * prevent further errors we will unload the hook.
- */
- pr_err("error in hook, unloading: %s",
- hook_node->name);
- acpi_battery_hook_unregister_unlocked(hook_node);
- }
- }
- mutex_unlock(&hook_mutex);
-}
-
-static void battery_hook_remove_battery(struct acpi_battery *battery)
-{
- struct acpi_battery_hook *hook;
-
- mutex_lock(&hook_mutex);
- /*
- * Before removing the hook, we need to remove all
- * custom attributes from the battery.
- */
- list_for_each_entry(hook, &battery_hook_list, list) {
- hook->remove_battery(battery->bat, hook);
- }
- /* Then, just remove the battery from the list */
- list_del(&battery->list);
- mutex_unlock(&hook_mutex);
-}
-
-static void __exit battery_hook_exit(void)
-{
- struct acpi_battery_hook *hook;
- struct acpi_battery_hook *ptr;
- /*
- * At this point, the acpi_bus_unregister_driver()
- * has called remove for all batteries. We just
- * need to remove the hooks.
- */
- list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
- acpi_battery_hook_unregister(hook);
- }
- mutex_destroy(&hook_mutex);
-}
-
static int sysfs_add_battery(struct acpi_battery *battery)
{
bool extended_info_available = test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
@@ -1052,7 +895,7 @@ static int sysfs_add_battery(struct acpi_battery *battery)
battery->bat = NULL;
return result;
}
- battery_hook_add_battery(battery);
+ acpi_battery_add_hooks(&battery->hooks_list_entry, battery->bat);
return 0;
}
@@ -1061,7 +904,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
if (!battery->bat)
return;
- battery_hook_remove_battery(battery);
+ acpi_battery_remove_hooks(&battery->hooks_list_entry);
power_supply_unregister(battery->bat);
battery->bat = NULL;
}
@@ -1571,7 +1414,6 @@ static int __init acpi_battery_init(void)
static void __exit acpi_battery_exit(void)
{
platform_driver_unregister(&acpi_battery_driver);
- battery_hook_exit();
}
module_init(acpi_battery_init);
diff --git a/drivers/acpi/battery_hooks.c b/drivers/acpi/battery_hooks.c
new file mode 100644
index 000000000000..ca3f9876cb09
--- /dev/null
+++ b/drivers/acpi/battery_hooks.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ACPI Battery Hooks
+ *
+ * Provides helpers for registering and unregistering battery hooks for
+ * drivers that use platform-specific extensions to ACPI-enumerated
+ * batteries (both ACPI Control Method batteries and Smart Battery System
+ * batteries).
+ */
+
+#define pr_fmt(fmt) "ACPI: battery: " fmt
+
+#include <linux/cleanup.h>
+#include <linux/device.h>
+#include <linux/export.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/power_supply.h>
+#include <acpi/battery.h>
+
+static LIST_HEAD(acpi_battery_list);
+static LIST_HEAD(battery_hook_list);
+static DEFINE_MUTEX(hook_mutex);
+
+static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
+{
+ struct acpi_battery_hooks_list_entry *entry;
+
+ /*
+ * In order to remove a hook, we first need to
+ * de-register all the batteries that are registered.
+ */
+ list_for_each_entry(entry, &acpi_battery_list, list_entry) {
+ if (!hook->remove_battery(entry->battery, hook))
+ power_supply_changed(entry->battery);
+ }
+ list_del_init(&hook->list);
+
+ pr_info("hook unregistered: %s\n", hook->name);
+}
+
+void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
+{
+ guard(mutex)(&hook_mutex);
+
+ /*
+ * Ignore already unregistered battery hooks. This might happen
+ * if a battery hook was previously unloaded due to an error when
+ * adding a new battery.
+ */
+ if (!list_empty(&hook->list))
+ acpi_battery_hook_unregister_unlocked(hook);
+}
+EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
+
+void acpi_battery_hook_register(struct acpi_battery_hook *hook)
+{
+ struct acpi_battery_hooks_list_entry *entry;
+
+ guard(mutex)(&hook_mutex);
+
+ list_add(&hook->list, &battery_hook_list);
+ /*
+ * Now that the driver is registered, we need
+ * to notify the hook that a battery is available
+ * for each battery, so that the driver may add
+ * its attributes.
+ */
+ list_for_each_entry(entry, &acpi_battery_list, list_entry) {
+ if (hook->add_battery(entry->battery, hook)) {
+ /*
+ * If a add-battery returns non-zero,
+ * the registration of the hook has failed,
+ * and we will not add it to the list of loaded
+ * hooks.
+ */
+ pr_err("hook failed to load: %s\n", hook->name);
+ acpi_battery_hook_unregister_unlocked(hook);
+ return;
+ }
+
+ power_supply_changed(entry->battery);
+ }
+ pr_info("new hook: %s\n", hook->name);
+}
+EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
+
+static void devm_acpi_battery_hook_unregister(void *data)
+{
+ struct acpi_battery_hook *hook = data;
+
+ acpi_battery_hook_unregister(hook);
+}
+
+int devm_acpi_battery_hook_register(struct device *dev,
+ struct acpi_battery_hook *hook)
+{
+ acpi_battery_hook_register(hook);
+
+ return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
+}
+EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
+
+/*
+ * This function gets called right after the battery sysfs
+ * attributes have been added, so that the drivers that
+ * define custom sysfs attributes can add their own.
+ */
+void acpi_battery_add_hooks(struct acpi_battery_hooks_list_entry *entry,
+ struct power_supply *battery)
+{
+ struct acpi_battery_hook *hook_node, *tmp;
+
+ entry->battery = battery;
+
+ guard(mutex)(&hook_mutex);
+
+ list_add(&entry->list_entry, &acpi_battery_list);
+ /*
+ * Since we added a new battery to the list, we need to
+ * iterate over the hooks and call add_battery for each
+ * hook that was registered. This usually happens
+ * when a battery gets hotplugged or initialized
+ * during the battery module initialization.
+ */
+ list_for_each_entry_safe(hook_node, tmp, &battery_hook_list, list) {
+ if (hook_node->add_battery(entry->battery, hook_node)) {
+ /*
+ * The notification of the hook has failed, to
+ * prevent further errors we will unload the hook.
+ */
+ pr_err("error in hook, unloading: %s\n", hook_node->name);
+ acpi_battery_hook_unregister_unlocked(hook_node);
+ }
+ }
+}
+EXPORT_SYMBOL_NS_GPL(acpi_battery_add_hooks, "ACPI_BATTERY_HOOKS");
+
+void acpi_battery_remove_hooks(struct acpi_battery_hooks_list_entry *entry)
+{
+ struct acpi_battery_hook *hook;
+
+ guard(mutex)(&hook_mutex);
+ /*
+ * Before removing the hook, we need to remove all
+ * custom attributes from the battery.
+ */
+ list_for_each_entry(hook, &battery_hook_list, list)
+ hook->remove_battery(entry->battery, hook);
+
+ /* Then, just remove the battery from the list */
+ list_del(&entry->list_entry);
+ entry->battery = NULL;
+}
+EXPORT_SYMBOL_NS_GPL(acpi_battery_remove_hooks, "ACPI_BATTERY_HOOKS");
+
+MODULE_DESCRIPTION("ACPI battery hooks");
+MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index f10bbf13c242..f80a6294953a 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -36,6 +36,7 @@
MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
MODULE_DESCRIPTION("Smart Battery System ACPI interface driver");
MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("ACPI_BATTERY_HOOKS");
static unsigned int cache_time = 1000;
module_param(cache_time, uint, 0644);
@@ -54,6 +55,7 @@ struct acpi_battery {
struct power_supply *bat;
struct power_supply_desc bat_desc;
struct acpi_sbs *sbs;
+ struct acpi_battery_hooks_list_entry hooks_list_entry;
unsigned long update_time;
char name[8];
char manufacturer_name[ACPI_SBS_BLOCK_MAX];
@@ -555,6 +557,8 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
goto end;
}
+ acpi_battery_add_hooks(&battery->hooks_list_entry, battery->bat);
+
end:
pr_info("%s [%s]: Battery Slot [%s] (battery %s)\n",
ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
@@ -566,8 +570,10 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
{
struct acpi_battery *battery = &sbs->battery[id];
- if (battery->bat)
+ if (battery->bat) {
+ acpi_battery_remove_hooks(&battery->hooks_list_entry);
power_supply_unregister(battery->bat);
+ }
}
static int acpi_charger_add(struct acpi_sbs *sbs)
diff --git a/include/acpi/battery.h b/include/acpi/battery.h
index 08c7e37996bf..6360f102a4e8 100644
--- a/include/acpi/battery.h
+++ b/include/acpi/battery.h
@@ -18,9 +18,18 @@ struct acpi_battery_hook {
struct list_head list;
};
+struct acpi_battery_hooks_list_entry {
+ struct list_head list_entry;
+ struct power_supply *battery;
+};
+
void acpi_battery_hook_register(struct acpi_battery_hook *hook);
void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
int devm_acpi_battery_hook_register(struct device *dev,
struct acpi_battery_hook *hook);
+void acpi_battery_add_hooks(struct acpi_battery_hooks_list_entry *entry,
+ struct power_supply *battery);
+void acpi_battery_remove_hooks(struct acpi_battery_hooks_list_entry *entry);
+
#endif
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 3/3] hwmon: (applesmc) add charge_control_end_threshold support
2026-09-30 22:26 [PATCH v3 0/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
2026-09-30 22:26 ` [PATCH v3 2/3] ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries Jordan Brough
@ 2026-09-30 22:26 ` Jordan Brough
2 siblings, 0 replies; 8+ messages in thread
From: Jordan Brough @ 2026-09-30 22:26 UTC (permalink / raw)
To: Guenter Roeck, Henrik Rydberg
Cc: Jordan Brough, Michal Szpakowski, linux-hwmon, linux-kernel,
Rafael J. Wysocki
Intel MacBooks keep the battery charge limit in the SMC key BCLM, and
some also have BFCL, which sets the threshold for the MagSafe LED.
Expose BCLM as charge_control_end_threshold through the power_supply
extension API, attached to the battery with the ACPI battery hooks.
Below 100%, BFCL is set 3 points below BCLM so that the LED turns green
before charging stops. On a MacBookAir6,2 the LED turns green about 0.75
points above BFCL and charging stops about 0.25 points below BCLM, so
this leaves about 2 points; other models were not measured. BFCL is only
written if the SMC has the key, and a failure to write it is only logged.
The SMC ignores BCLM values it does not accept but still reports
success, so read the value back and return -EINVAL if it was not applied.
Limits below 20 are rejected. 20 is known to work and 10 is not accepted
by the SMC on the hardware tested; the exact floor in between was not
determined.
Serialize the writes with applesmc_bat_lock, and notify userspace of
changes with power_supply_changed().
Tested-by: Michal Szpakowski <michi.szpakowski@gmail.com>
Signed-off-by: Jordan Brough <jordan@brough.org>
---
drivers/hwmon/Kconfig | 1 +
drivers/hwmon/applesmc.c | 146 +++++++++++++++++++++++++++++++++++++++
2 files changed, 147 insertions(+)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index fecff8610ea8..d627b4cf11e5 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -380,6 +380,7 @@ config SENSORS_FAM15H_POWER
config SENSORS_APPLESMC
tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
depends on INPUT && X86
+ depends on POWER_SUPPLY || POWER_SUPPLY=n
select NEW_LEDS
select LEDS_CLASS
help
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index d0baa10502f7..b6d9ca302730 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -33,6 +33,8 @@
#include <linux/workqueue.h>
#include <linux/err.h>
#include <linux/bits.h>
+#include <linux/power_supply.h>
+#include <acpi/battery.h>
#include <asm/barrier.h>
/* data port used by Apple SMC */
@@ -76,6 +78,20 @@
#define TEMP_SENSOR_TYPE "sp78"
+/*
+ * BCLM caps charging at a percentage. BFCL only sets when the charging LED
+ * switches from orange to green.
+ */
+#define BATTERY_CHARGE_LIMIT_KEY "BCLM" /* r/w ui8 */
+#define BATTERY_CHARGE_LIMIT_LED_KEY "BFCL" /* r/w ui8 */
+
+/*
+ * Points kept between BCLM and BFCL so the LED turns green before charging
+ * stops. Measured on a MacBookAir6,2, where a margin of 1 only just ties;
+ * 3 leaves headroom for other models.
+ */
+#define APPLESMC_BATTERY_CHARGE_LIMIT_LED_MARGIN 3
+
/* List of keys used to read/write fan speeds */
static const char *const fan_speed_fmt[] = {
"F%dAc", /* actual speed */
@@ -131,6 +147,8 @@ static struct applesmc_registers {
int num_light_sensors; /* number of light sensors */
bool has_accelerometer; /* has motion sensor */
bool has_key_backlight; /* has keyboard backlight */
+ bool has_battery_charge_limit; /* has BCLM battery charge limit */
+ bool has_battery_charge_limit_led; /* has BFCL MagSafe LED charge limit */
bool init_complete; /* true when fully initialized */
struct applesmc_entry *cache; /* cached key entries */
const char **index; /* temperature key index */
@@ -633,6 +651,12 @@ static int applesmc_init_smcreg_try(void)
if (ret)
return ret;
ret = applesmc_has_key(BACKLIGHT_KEY, &s->has_key_backlight);
+ if (ret)
+ return ret;
+ ret = applesmc_has_key(BATTERY_CHARGE_LIMIT_KEY, &s->has_battery_charge_limit);
+ if (ret)
+ return ret;
+ ret = applesmc_has_key(BATTERY_CHARGE_LIMIT_LED_KEY, &s->has_battery_charge_limit_led);
if (ret)
return ret;
@@ -724,6 +748,120 @@ static struct platform_driver applesmc_driver = {
},
};
+static DEFINE_MUTEX(applesmc_bat_lock);
+
+static int applesmc_bat_get_property(struct power_supply *psy,
+ const struct power_supply_ext *ext,
+ void *data,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ u8 limit;
+ int ret;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD:
+ scoped_guard(mutex, &applesmc_bat_lock)
+ ret = applesmc_read_key(BATTERY_CHARGE_LIMIT_KEY, &limit, 1);
+ if (ret)
+ return ret;
+ val->intval = limit;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int applesmc_bat_set_property(struct power_supply *psy,
+ const struct power_supply_ext *ext,
+ void *data,
+ enum power_supply_property psp,
+ const union power_supply_propval *val)
+{
+ u8 limit, led_limit, readback;
+ int ret;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD:
+ /* 20 is known to work and 10 is not accepted; the floor is unknown. */
+ if (val->intval < 20 || val->intval > 100)
+ return -EINVAL;
+
+ limit = val->intval;
+ /* At 100% charging is never cut short, so no margin is needed. */
+ led_limit = limit < 100 ?
+ limit - APPLESMC_BATTERY_CHARGE_LIMIT_LED_MARGIN : limit;
+
+ scoped_guard(mutex, &applesmc_bat_lock) {
+ ret = applesmc_write_key(BATTERY_CHARGE_LIMIT_KEY, &limit, 1);
+ if (ret)
+ return ret;
+
+ /*
+ * The SMC silently ignores values it does not accept and
+ * still reports success, so read the limit back.
+ */
+ ret = applesmc_read_key(BATTERY_CHARGE_LIMIT_KEY, &readback, 1);
+ if (ret)
+ return ret;
+ if (readback != limit)
+ return -EINVAL;
+
+ if (smcreg.has_battery_charge_limit_led) {
+ ret = applesmc_write_key(BATTERY_CHARGE_LIMIT_LED_KEY,
+ &led_limit, 1);
+ /* BCLM is already applied, so this is not an error. */
+ if (ret)
+ pr_warn("failed to update MagSafe LED threshold (BFCL): %d\n",
+ ret);
+ }
+ }
+
+ power_supply_changed(psy);
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int applesmc_bat_property_is_writeable(struct power_supply *psy,
+ const struct power_supply_ext *ext,
+ void *data,
+ enum power_supply_property psp)
+{
+ return psp == POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD;
+}
+
+static const enum power_supply_property applesmc_bat_props[] = {
+ POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD,
+};
+
+static const struct power_supply_ext applesmc_bat_ext = {
+ .name = "applesmc-charge-control",
+ .properties = applesmc_bat_props,
+ .num_properties = ARRAY_SIZE(applesmc_bat_props),
+ .get_property = applesmc_bat_get_property,
+ .set_property = applesmc_bat_set_property,
+ .property_is_writeable = applesmc_bat_property_is_writeable,
+};
+
+static int applesmc_bat_add(struct power_supply *battery, struct acpi_battery_hook *hook)
+{
+ return power_supply_register_extension(battery, &applesmc_bat_ext, &pdev->dev, NULL);
+}
+
+static int applesmc_bat_remove(struct power_supply *battery, struct acpi_battery_hook *hook)
+{
+ power_supply_unregister_extension(battery, &applesmc_bat_ext);
+ return 0;
+}
+
+static struct acpi_battery_hook applesmc_bat_hook = {
+ .name = "Apple SMC Battery Charge Control",
+ .add_battery = applesmc_bat_add,
+ .remove_battery = applesmc_bat_remove,
+};
+
/*
* applesmc_calibrate - Set our "resting" values. Callers must
* hold applesmc_lock.
@@ -1563,6 +1701,10 @@ static int __init applesmc_init(void)
goto out_light_ledclass;
}
+ if (smcreg.has_battery_charge_limit &&
+ IS_REACHABLE(CONFIG_ACPI_BATTERY_HOOKS))
+ acpi_battery_hook_register(&applesmc_bat_hook);
+
return 0;
out_light_ledclass:
@@ -1589,6 +1731,10 @@ static int __init applesmc_init(void)
static void __exit applesmc_exit(void)
{
+ if (smcreg.has_battery_charge_limit &&
+ IS_REACHABLE(CONFIG_ACPI_BATTERY_HOOKS))
+ acpi_battery_hook_unregister(&applesmc_bat_hook);
+
hwmon_device_unregister(hwmon_dev);
applesmc_release_key_backlight();
applesmc_release_light_sensor();
--
2.56.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
@ 2026-09-30 23:19 ` Armin Wolf
2026-10-01 0:21 ` Jonathan Woithe
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Armin Wolf @ 2026-09-30 23:19 UTC (permalink / raw)
To: Jordan Brough, Rafael J. Wysocki, Len Brown, Corentin Chary,
Luke D. Jones, Denis Benato, Hans de Goede, Ilpo Järvinen,
Antheas Kapenekakis, Matthew Garrett, Pali Rohár,
Jonathan Woithe, Mark Pearson, Derek J. Clark, Ike Panhc,
Henrique de Moraes Holschuh, Matan Ziv-Av, Nikita Kravets,
Joaquín Ignacio Aramendía, Joshua Grisham,
Jeremy Soller, System76 Product Development, Azael Avalos,
Thomas Weißschuh, Benson Leung, Guenter Roeck,
Sebastian Reichel
Cc: linux-acpi, linux-kernel, platform-driver-x86, ibm-acpi-devel,
chrome-platform, linux-pm
Am 01.10.26 um 00:26 schrieb Jordan Brough:
> Rename battery_hook_register(), battery_hook_unregister() and
> devm_battery_hook_register() to acpi_battery_hook_register(),
> acpi_battery_hook_unregister() and devm_acpi_battery_hook_register(), so
> that the exported ACPI battery hook API has a consistent namespace, and
> update all in-tree callers.
>
> No functional change.
For the uniwill-laptop changes:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Jordan Brough <jordan@brough.org>
> ---
> drivers/acpi/battery.c | 30 ++++++++++----------
> drivers/platform/x86/asus-wmi.c | 4 +--
> drivers/platform/x86/ayaneo-ec.c | 2 +-
> drivers/platform/x86/dell/dell-laptop.c | 4 +--
> drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
> drivers/platform/x86/fujitsu-laptop.c | 4 +--
> drivers/platform/x86/huawei-wmi.c | 4 +--
> drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +--
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +--
> drivers/platform/x86/lenovo/wmi-other.c | 4 +--
> drivers/platform/x86/lg-laptop.c | 4 +--
> drivers/platform/x86/msi-ec.c | 4 +--
> drivers/platform/x86/oxpec.c | 2 +-
> drivers/platform/x86/samsung-galaxybook.c | 3 +-
> drivers/platform/x86/samsung-laptop.c | 4 +--
> drivers/platform/x86/system76_acpi.c | 4 +--
> drivers/platform/x86/toshiba_acpi.c | 4 +--
> drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
> drivers/power/supply/cros_charge-control.c | 2 +-
> include/acpi/battery.h | 7 +++--
> 20 files changed, 50 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 8599949f8786..306bb2088ca6 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -821,7 +821,7 @@ static LIST_HEAD(acpi_battery_list);
> static LIST_HEAD(battery_hook_list);
> static DEFINE_MUTEX(hook_mutex);
>
> -static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> +static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -838,7 +838,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> pr_info("hook unregistered: %s\n", hook->name);
> }
>
> -void battery_hook_unregister(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
> {
> mutex_lock(&hook_mutex);
> /*
> @@ -847,13 +847,13 @@ void battery_hook_unregister(struct acpi_battery_hook *hook)
> * adding a new battery.
> */
> if (!list_empty(&hook->list))
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
>
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_unregister);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
>
> -void battery_hook_register(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -874,7 +874,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> * hooks.
> */
> pr_err("hook failed to load: %s", hook->name);
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
> goto end;
> }
>
> @@ -884,22 +884,22 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> end:
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_register);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
>
> -static void devm_battery_hook_unregister(void *data)
> +static void devm_acpi_battery_hook_unregister(void *data)
> {
> struct acpi_battery_hook *hook = data;
>
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
>
> -int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
> +int devm_acpi_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
> {
> - battery_hook_register(hook);
> + acpi_battery_hook_register(hook);
>
> - return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
> + return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
> }
> -EXPORT_SYMBOL_GPL(devm_battery_hook_register);
> +EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
>
> /*
> * This function gets called right after the battery sysfs
> @@ -928,7 +928,7 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
> */
> pr_err("error in hook, unloading: %s",
> hook_node->name);
> - battery_hook_unregister_unlocked(hook_node);
> + acpi_battery_hook_unregister_unlocked(hook_node);
> }
> }
> mutex_unlock(&hook_mutex);
> @@ -961,7 +961,7 @@ static void __exit battery_hook_exit(void)
> * need to remove the hooks.
> */
> list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
> mutex_destroy(&hook_mutex);
> }
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index a65090429ca7..c274f456863c 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -1681,14 +1681,14 @@ static void asus_wmi_battery_init(struct asus_wmi *asus)
> asus->battery_rsoc_available = false;
> if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) {
> asus->battery_rsoc_available = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> }
> }
>
> static void asus_wmi_battery_exit(struct asus_wmi *asus)
> {
> if (asus->battery_rsoc_available)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* LEDs ***********************************************************************/
> diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
> index 41a24e091248..3ba87bd16c9a 100644
> --- a/drivers/platform/x86/ayaneo-ec.c
> +++ b/drivers/platform/x86/ayaneo-ec.c
> @@ -493,7 +493,7 @@ static int ayaneo_ec_probe(struct platform_device *pdev)
> data->battery_hook.add_battery = ayaneo_add_battery;
> data->battery_hook.remove_battery = ayaneo_remove_battery;
> data->battery_hook.name = "Ayaneo Battery";
> - ret = devm_battery_hook_register(&pdev->dev, &data->battery_hook);
> + ret = devm_acpi_battery_hook_register(&pdev->dev, &data->battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
> index 89e85c7f7132..cad2bd06f28a 100644
> --- a/drivers/platform/x86/dell/dell-laptop.c
> +++ b/drivers/platform/x86/dell/dell-laptop.c
> @@ -2446,13 +2446,13 @@ static void __init dell_battery_init(struct device *dev)
> battery_supported_modes = battery_get_supported_modes();
>
> if (battery_supported_modes != 0)
> - battery_hook_register(&dell_battery_hook);
> + acpi_battery_hook_register(&dell_battery_hook);
> }
>
> static void dell_battery_exit(void)
> {
> if (battery_supported_modes != 0)
> - battery_hook_unregister(&dell_battery_hook);
> + acpi_battery_hook_unregister(&dell_battery_hook);
> }
>
> static int __init dell_init(void)
> diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
> index f8903ced461b..6f0504d7519e 100644
> --- a/drivers/platform/x86/dell/dell-wmi-ddv.c
> +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
> @@ -972,7 +972,7 @@ static int dell_wmi_ddv_battery_add(struct dell_wmi_ddv_data *data)
> data->eppid_attr.attr.mode = 0444;
> data->eppid_attr.show = eppid_show;
>
> - return devm_battery_hook_register(&data->wdev->dev, &data->hook);
> + return devm_acpi_battery_hook_register(&data->wdev->dev, &data->hook);
> }
>
> static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum dell_ddv_method method)
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index ea543deef68f..96e74c4fdb29 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -267,7 +267,7 @@ static int fujitsu_battery_charge_control_add(struct device *dev)
> return -ENODEV;
>
> priv->charge_control_supported = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
> }
> @@ -277,7 +277,7 @@ static void fujitsu_battery_charge_control_remove(struct device *dev)
> struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>
> if (priv->charge_control_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* Hardware access for LCD brightness control */
> diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
> index d6aaf14d66a5..8cc0e900e984 100644
> --- a/drivers/platform/x86/huawei-wmi.c
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -512,7 +512,7 @@ static void huawei_wmi_battery_setup(struct device *dev)
> return;
> }
>
> - battery_hook_register(&huawei_wmi_battery_hook);
> + acpi_battery_hook_register(&huawei_wmi_battery_hook);
> device_create_file(dev, &dev_attr_charge_control_thresholds);
> }
>
> @@ -521,7 +521,7 @@ static void huawei_wmi_battery_exit(struct device *dev)
> struct huawei_wmi *huawei = dev_get_drvdata(dev);
>
> if (huawei->battery_available) {
> - battery_hook_unregister(&huawei_wmi_battery_hook);
> + acpi_battery_hook_unregister(&huawei_wmi_battery_hook);
> device_remove_file(dev, &dev_attr_charge_control_thresholds);
> }
> }
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> index 8213524504ee..1d90d4591641 100644
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
> @@ -2197,8 +2197,8 @@ static int ideapad_check_features(struct ideapad_private *priv)
> priv->battery_hook.remove_battery = ideapad_battery_remove;
> priv->battery_hook.name = "Ideapad Battery Extension";
>
> - err = devm_battery_hook_register(&priv->platform_device->dev,
> - &priv->battery_hook);
> + err = devm_acpi_battery_hook_register(&priv->platform_device->dev,
> + &priv->battery_hook);
> if (err)
> return err;
> }
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 1661f070c571..eb5ad18855db 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -10021,13 +10021,13 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
> battery_quirk_table,
> ARRAY_SIZE(battery_quirk_table));
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void tpacpi_battery_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> static struct ibm_struct battery_driver_data = {
> diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
> index fbb32bf404f2..0450634ac1dd 100644
> --- a/drivers/platform/x86/lenovo/wmi-other.c
> +++ b/drivers/platform/x86/lenovo/wmi-other.c
> @@ -946,7 +946,7 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
> priv->battery_hook.name = "Lenovo WMI Other Battery Extension";
> priv->bh_registered = true;
>
> - battery_hook_register(&priv->battery_hook);
> + acpi_battery_hook_register(&priv->battery_hook);
> }
>
> /**
> @@ -960,7 +960,7 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
> if (!priv->bh_registered)
> return;
>
> - battery_hook_unregister(&priv->battery_hook);
> + acpi_battery_hook_unregister(&priv->battery_hook);
> priv->bh_registered = false;
> }
>
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index 36ad1e269443..e788671307c4 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -1053,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
> if (ret)
> goto out_platform_device;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> @@ -1068,7 +1068,7 @@ static void acpi_remove(struct platform_device *pdev)
> {
> sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group);
>
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> platform_device_unregister(pf_device);
> pf_device = NULL;
> platform_driver_unregister(&pf_driver);
> diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
> index 566dfc73cb67..cb30a1d5b546 100644
> --- a/drivers/platform/x86/msi-ec.c
> +++ b/drivers/platform/x86/msi-ec.c
> @@ -1428,13 +1428,13 @@ static int __init msi_ec_init(void)
> if (result < 0)
> return result;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void __exit msi_ec_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> MODULE_LICENSE("GPL");
> diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c
> index 34bb17fca148..318f194e72b5 100644
> --- a/drivers/platform/x86/oxpec.c
> +++ b/drivers/platform/x86/oxpec.c
> @@ -956,7 +956,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
> return PTR_ERR(hwdev);
>
> if (oxp_psy_ext_supported()) {
> - ret = devm_battery_hook_register(dev, &battery_hook);
> + ret = devm_acpi_battery_hook_register(dev, &battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/samsung-galaxybook.c b/drivers/platform/x86/samsung-galaxybook.c
> index 99f72b204a51..a4f7dbb76214 100644
> --- a/drivers/platform/x86/samsung-galaxybook.c
> +++ b/drivers/platform/x86/samsung-galaxybook.c
> @@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct samsung_galaxybook *galaxybo
> galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
> galaxybook->battery_hook.name = "Samsung Galaxy Book Battery Extension";
>
> - return devm_battery_hook_register(&galaxybook->platform->dev, &galaxybook->battery_hook);
> + return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
> + &galaxybook->battery_hook);
> }
>
> /*
> diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
> index 710f3d5bf84c..43fa1dc2773c 100644
> --- a/drivers/platform/x86/samsung-laptop.c
> +++ b/drivers/platform/x86/samsung-laptop.c
> @@ -1142,8 +1142,8 @@ static int __init samsung_battery_hook_init(struct samsung_laptop *samsung)
> samsung->battery_hook.add_battery = samsung_battery_add;
> samsung->battery_hook.remove_battery = samsung_battery_remove;
> samsung->battery_hook.name = "Samsung Battery Extension";
> - retval = devm_battery_hook_register(&samsung->platform_device->dev,
> - &samsung->battery_hook);
> + retval = devm_acpi_battery_hook_register(&samsung->platform_device->dev,
> + &samsung->battery_hook);
> }
>
> return retval;
> diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
> index dd7b1b07c316..33968b61f0b2 100644
> --- a/drivers/platform/x86/system76_acpi.c
> +++ b/drivers/platform/x86/system76_acpi.c
> @@ -288,12 +288,12 @@ static struct acpi_battery_hook system76_battery_hook = {
>
> static void system76_battery_init(void)
> {
> - battery_hook_register(&system76_battery_hook);
> + acpi_battery_hook_register(&system76_battery_hook);
> }
>
> static void system76_battery_exit(void)
> {
> - battery_hook_unregister(&system76_battery_hook);
> + acpi_battery_hook_unregister(&system76_battery_hook);
> }
>
> // Get the airplane mode LED brightness
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index a0b8060836d0..4cc879bc267a 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -3301,7 +3301,7 @@ static void toshiba_acpi_remove(struct platform_device *pdev)
> }
>
> if (dev->battery_charge_mode_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
>
> if (toshiba_acpi)
> toshiba_acpi = NULL;
> @@ -3566,7 +3566,7 @@ static int toshiba_acpi_probe(struct platform_device *pdev)
> * set, this must be done after toshiba_acpi is assigned.
> */
> if (dev->battery_charge_mode_supported)
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
> index 7a2eeaec4c96..d76695c2c765 100644
> --- a/drivers/platform/x86/uniwill/uniwill-acpi.c
> +++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
> @@ -2165,7 +2165,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
> data->hook.add_battery = uniwill_add_battery;
> data->hook.remove_battery = uniwill_remove_battery;
>
> - return devm_battery_hook_register(data->dev, &data->hook);
> + return devm_acpi_battery_hook_register(data->dev, &data->hook);
> }
>
> static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action, void *dummy)
> diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
> index e0f168624807..1901bbcffd73 100644
> --- a/drivers/power/supply/cros_charge-control.c
> +++ b/drivers/power/supply/cros_charge-control.c
> @@ -315,7 +315,7 @@ static int cros_chctl_probe(struct platform_device *pdev)
> if (ret < 0)
> return ret;
>
> - return devm_battery_hook_register(dev, &priv->battery_hook);
> + return devm_acpi_battery_hook_register(dev, &priv->battery_hook);
> }
>
> static const struct platform_device_id cros_chctl_id[] = {
> diff --git a/include/acpi/battery.h b/include/acpi/battery.h
> index c93f16dfb944..08c7e37996bf 100644
> --- a/include/acpi/battery.h
> +++ b/include/acpi/battery.h
> @@ -18,8 +18,9 @@ struct acpi_battery_hook {
> struct list_head list;
> };
>
> -void battery_hook_register(struct acpi_battery_hook *hook);
> -void battery_hook_unregister(struct acpi_battery_hook *hook);
> -int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook);
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook);
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
> +int devm_acpi_battery_hook_register(struct device *dev,
> + struct acpi_battery_hook *hook);
>
> #endif
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
2026-09-30 23:19 ` Armin Wolf
@ 2026-10-01 0:21 ` Jonathan Woithe
2026-10-01 1:14 ` Derek J. Clark
2026-10-01 13:19 ` Mark Pearson
3 siblings, 0 replies; 8+ messages in thread
From: Jonathan Woithe @ 2026-10-01 0:21 UTC (permalink / raw)
To: Jordan Brough
Cc: Rafael J. Wysocki, Len Brown, Corentin Chary, Luke D. Jones,
Denis Benato, Hans de Goede, Ilpo Järvinen,
Antheas Kapenekakis, Matthew Garrett, Pali Rohár,
Armin Wolf, Mark Pearson, Derek J. Clark, Ike Panhc,
Henrique de Moraes Holschuh, Matan Ziv-Av, Nikita Kravets,
Joaquín Ignacio Aramendía, Joshua Grisham,
Jeremy Soller, System76 Product Development, Azael Avalos,
Thomas Weißschuh, Benson Leung, Guenter Roeck,
Sebastian Reichel, linux-acpi, linux-kernel, platform-driver-x86,
ibm-acpi-devel, chrome-platform, linux-pm
On Wed, Sep 30, 2026 at 04:26:33PM -0600, Jordan Brough wrote:
> Rename battery_hook_register(), battery_hook_unregister() and
> devm_battery_hook_register() to acpi_battery_hook_register(),
> acpi_battery_hook_unregister() and devm_acpi_battery_hook_register(), so
> that the exported ACPI battery hook API has a consistent namespace, and
> update all in-tree callers.
>
> No functional change.
For the fujitsu-laptop changes:
Signed-off-by: Jonathan Woithe <jwoithe@just42.net>
> Signed-off-by: Jordan Brough <jordan@brough.org>
> ---
> drivers/acpi/battery.c | 30 ++++++++++----------
> drivers/platform/x86/asus-wmi.c | 4 +--
> drivers/platform/x86/ayaneo-ec.c | 2 +-
> drivers/platform/x86/dell/dell-laptop.c | 4 +--
> drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
> drivers/platform/x86/fujitsu-laptop.c | 4 +--
> drivers/platform/x86/huawei-wmi.c | 4 +--
> drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +--
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +--
> drivers/platform/x86/lenovo/wmi-other.c | 4 +--
> drivers/platform/x86/lg-laptop.c | 4 +--
> drivers/platform/x86/msi-ec.c | 4 +--
> drivers/platform/x86/oxpec.c | 2 +-
> drivers/platform/x86/samsung-galaxybook.c | 3 +-
> drivers/platform/x86/samsung-laptop.c | 4 +--
> drivers/platform/x86/system76_acpi.c | 4 +--
> drivers/platform/x86/toshiba_acpi.c | 4 +--
> drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
> drivers/power/supply/cros_charge-control.c | 2 +-
> include/acpi/battery.h | 7 +++--
> 20 files changed, 50 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 8599949f8786..306bb2088ca6 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -821,7 +821,7 @@ static LIST_HEAD(acpi_battery_list);
> static LIST_HEAD(battery_hook_list);
> static DEFINE_MUTEX(hook_mutex);
>
> -static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> +static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -838,7 +838,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> pr_info("hook unregistered: %s\n", hook->name);
> }
>
> -void battery_hook_unregister(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
> {
> mutex_lock(&hook_mutex);
> /*
> @@ -847,13 +847,13 @@ void battery_hook_unregister(struct acpi_battery_hook *hook)
> * adding a new battery.
> */
> if (!list_empty(&hook->list))
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
>
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_unregister);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
>
> -void battery_hook_register(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -874,7 +874,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> * hooks.
> */
> pr_err("hook failed to load: %s", hook->name);
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
> goto end;
> }
>
> @@ -884,22 +884,22 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> end:
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_register);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
>
> -static void devm_battery_hook_unregister(void *data)
> +static void devm_acpi_battery_hook_unregister(void *data)
> {
> struct acpi_battery_hook *hook = data;
>
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
>
> -int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
> +int devm_acpi_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
> {
> - battery_hook_register(hook);
> + acpi_battery_hook_register(hook);
>
> - return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
> + return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
> }
> -EXPORT_SYMBOL_GPL(devm_battery_hook_register);
> +EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
>
> /*
> * This function gets called right after the battery sysfs
> @@ -928,7 +928,7 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
> */
> pr_err("error in hook, unloading: %s",
> hook_node->name);
> - battery_hook_unregister_unlocked(hook_node);
> + acpi_battery_hook_unregister_unlocked(hook_node);
> }
> }
> mutex_unlock(&hook_mutex);
> @@ -961,7 +961,7 @@ static void __exit battery_hook_exit(void)
> * need to remove the hooks.
> */
> list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
> mutex_destroy(&hook_mutex);
> }
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index a65090429ca7..c274f456863c 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -1681,14 +1681,14 @@ static void asus_wmi_battery_init(struct asus_wmi *asus)
> asus->battery_rsoc_available = false;
> if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) {
> asus->battery_rsoc_available = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> }
> }
>
> static void asus_wmi_battery_exit(struct asus_wmi *asus)
> {
> if (asus->battery_rsoc_available)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* LEDs ***********************************************************************/
> diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
> index 41a24e091248..3ba87bd16c9a 100644
> --- a/drivers/platform/x86/ayaneo-ec.c
> +++ b/drivers/platform/x86/ayaneo-ec.c
> @@ -493,7 +493,7 @@ static int ayaneo_ec_probe(struct platform_device *pdev)
> data->battery_hook.add_battery = ayaneo_add_battery;
> data->battery_hook.remove_battery = ayaneo_remove_battery;
> data->battery_hook.name = "Ayaneo Battery";
> - ret = devm_battery_hook_register(&pdev->dev, &data->battery_hook);
> + ret = devm_acpi_battery_hook_register(&pdev->dev, &data->battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
> index 89e85c7f7132..cad2bd06f28a 100644
> --- a/drivers/platform/x86/dell/dell-laptop.c
> +++ b/drivers/platform/x86/dell/dell-laptop.c
> @@ -2446,13 +2446,13 @@ static void __init dell_battery_init(struct device *dev)
> battery_supported_modes = battery_get_supported_modes();
>
> if (battery_supported_modes != 0)
> - battery_hook_register(&dell_battery_hook);
> + acpi_battery_hook_register(&dell_battery_hook);
> }
>
> static void dell_battery_exit(void)
> {
> if (battery_supported_modes != 0)
> - battery_hook_unregister(&dell_battery_hook);
> + acpi_battery_hook_unregister(&dell_battery_hook);
> }
>
> static int __init dell_init(void)
> diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
> index f8903ced461b..6f0504d7519e 100644
> --- a/drivers/platform/x86/dell/dell-wmi-ddv.c
> +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
> @@ -972,7 +972,7 @@ static int dell_wmi_ddv_battery_add(struct dell_wmi_ddv_data *data)
> data->eppid_attr.attr.mode = 0444;
> data->eppid_attr.show = eppid_show;
>
> - return devm_battery_hook_register(&data->wdev->dev, &data->hook);
> + return devm_acpi_battery_hook_register(&data->wdev->dev, &data->hook);
> }
>
> static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum dell_ddv_method method)
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index ea543deef68f..96e74c4fdb29 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -267,7 +267,7 @@ static int fujitsu_battery_charge_control_add(struct device *dev)
> return -ENODEV;
>
> priv->charge_control_supported = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
> }
> @@ -277,7 +277,7 @@ static void fujitsu_battery_charge_control_remove(struct device *dev)
> struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>
> if (priv->charge_control_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* Hardware access for LCD brightness control */
> diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
> index d6aaf14d66a5..8cc0e900e984 100644
> --- a/drivers/platform/x86/huawei-wmi.c
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -512,7 +512,7 @@ static void huawei_wmi_battery_setup(struct device *dev)
> return;
> }
>
> - battery_hook_register(&huawei_wmi_battery_hook);
> + acpi_battery_hook_register(&huawei_wmi_battery_hook);
> device_create_file(dev, &dev_attr_charge_control_thresholds);
> }
>
> @@ -521,7 +521,7 @@ static void huawei_wmi_battery_exit(struct device *dev)
> struct huawei_wmi *huawei = dev_get_drvdata(dev);
>
> if (huawei->battery_available) {
> - battery_hook_unregister(&huawei_wmi_battery_hook);
> + acpi_battery_hook_unregister(&huawei_wmi_battery_hook);
> device_remove_file(dev, &dev_attr_charge_control_thresholds);
> }
> }
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> index 8213524504ee..1d90d4591641 100644
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
> @@ -2197,8 +2197,8 @@ static int ideapad_check_features(struct ideapad_private *priv)
> priv->battery_hook.remove_battery = ideapad_battery_remove;
> priv->battery_hook.name = "Ideapad Battery Extension";
>
> - err = devm_battery_hook_register(&priv->platform_device->dev,
> - &priv->battery_hook);
> + err = devm_acpi_battery_hook_register(&priv->platform_device->dev,
> + &priv->battery_hook);
> if (err)
> return err;
> }
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 1661f070c571..eb5ad18855db 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -10021,13 +10021,13 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
> battery_quirk_table,
> ARRAY_SIZE(battery_quirk_table));
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void tpacpi_battery_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> static struct ibm_struct battery_driver_data = {
> diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
> index fbb32bf404f2..0450634ac1dd 100644
> --- a/drivers/platform/x86/lenovo/wmi-other.c
> +++ b/drivers/platform/x86/lenovo/wmi-other.c
> @@ -946,7 +946,7 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
> priv->battery_hook.name = "Lenovo WMI Other Battery Extension";
> priv->bh_registered = true;
>
> - battery_hook_register(&priv->battery_hook);
> + acpi_battery_hook_register(&priv->battery_hook);
> }
>
> /**
> @@ -960,7 +960,7 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
> if (!priv->bh_registered)
> return;
>
> - battery_hook_unregister(&priv->battery_hook);
> + acpi_battery_hook_unregister(&priv->battery_hook);
> priv->bh_registered = false;
> }
>
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index 36ad1e269443..e788671307c4 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -1053,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
> if (ret)
> goto out_platform_device;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> @@ -1068,7 +1068,7 @@ static void acpi_remove(struct platform_device *pdev)
> {
> sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group);
>
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> platform_device_unregister(pf_device);
> pf_device = NULL;
> platform_driver_unregister(&pf_driver);
> diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
> index 566dfc73cb67..cb30a1d5b546 100644
> --- a/drivers/platform/x86/msi-ec.c
> +++ b/drivers/platform/x86/msi-ec.c
> @@ -1428,13 +1428,13 @@ static int __init msi_ec_init(void)
> if (result < 0)
> return result;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void __exit msi_ec_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> MODULE_LICENSE("GPL");
> diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c
> index 34bb17fca148..318f194e72b5 100644
> --- a/drivers/platform/x86/oxpec.c
> +++ b/drivers/platform/x86/oxpec.c
> @@ -956,7 +956,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
> return PTR_ERR(hwdev);
>
> if (oxp_psy_ext_supported()) {
> - ret = devm_battery_hook_register(dev, &battery_hook);
> + ret = devm_acpi_battery_hook_register(dev, &battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/samsung-galaxybook.c b/drivers/platform/x86/samsung-galaxybook.c
> index 99f72b204a51..a4f7dbb76214 100644
> --- a/drivers/platform/x86/samsung-galaxybook.c
> +++ b/drivers/platform/x86/samsung-galaxybook.c
> @@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct samsung_galaxybook *galaxybo
> galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
> galaxybook->battery_hook.name = "Samsung Galaxy Book Battery Extension";
>
> - return devm_battery_hook_register(&galaxybook->platform->dev, &galaxybook->battery_hook);
> + return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
> + &galaxybook->battery_hook);
> }
>
> /*
> diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
> index 710f3d5bf84c..43fa1dc2773c 100644
> --- a/drivers/platform/x86/samsung-laptop.c
> +++ b/drivers/platform/x86/samsung-laptop.c
> @@ -1142,8 +1142,8 @@ static int __init samsung_battery_hook_init(struct samsung_laptop *samsung)
> samsung->battery_hook.add_battery = samsung_battery_add;
> samsung->battery_hook.remove_battery = samsung_battery_remove;
> samsung->battery_hook.name = "Samsung Battery Extension";
> - retval = devm_battery_hook_register(&samsung->platform_device->dev,
> - &samsung->battery_hook);
> + retval = devm_acpi_battery_hook_register(&samsung->platform_device->dev,
> + &samsung->battery_hook);
> }
>
> return retval;
> diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
> index dd7b1b07c316..33968b61f0b2 100644
> --- a/drivers/platform/x86/system76_acpi.c
> +++ b/drivers/platform/x86/system76_acpi.c
> @@ -288,12 +288,12 @@ static struct acpi_battery_hook system76_battery_hook = {
>
> static void system76_battery_init(void)
> {
> - battery_hook_register(&system76_battery_hook);
> + acpi_battery_hook_register(&system76_battery_hook);
> }
>
> static void system76_battery_exit(void)
> {
> - battery_hook_unregister(&system76_battery_hook);
> + acpi_battery_hook_unregister(&system76_battery_hook);
> }
>
> // Get the airplane mode LED brightness
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index a0b8060836d0..4cc879bc267a 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -3301,7 +3301,7 @@ static void toshiba_acpi_remove(struct platform_device *pdev)
> }
>
> if (dev->battery_charge_mode_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
>
> if (toshiba_acpi)
> toshiba_acpi = NULL;
> @@ -3566,7 +3566,7 @@ static int toshiba_acpi_probe(struct platform_device *pdev)
> * set, this must be done after toshiba_acpi is assigned.
> */
> if (dev->battery_charge_mode_supported)
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
> index 7a2eeaec4c96..d76695c2c765 100644
> --- a/drivers/platform/x86/uniwill/uniwill-acpi.c
> +++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
> @@ -2165,7 +2165,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
> data->hook.add_battery = uniwill_add_battery;
> data->hook.remove_battery = uniwill_remove_battery;
>
> - return devm_battery_hook_register(data->dev, &data->hook);
> + return devm_acpi_battery_hook_register(data->dev, &data->hook);
> }
>
> static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action, void *dummy)
> diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
> index e0f168624807..1901bbcffd73 100644
> --- a/drivers/power/supply/cros_charge-control.c
> +++ b/drivers/power/supply/cros_charge-control.c
> @@ -315,7 +315,7 @@ static int cros_chctl_probe(struct platform_device *pdev)
> if (ret < 0)
> return ret;
>
> - return devm_battery_hook_register(dev, &priv->battery_hook);
> + return devm_acpi_battery_hook_register(dev, &priv->battery_hook);
> }
>
> static const struct platform_device_id cros_chctl_id[] = {
> diff --git a/include/acpi/battery.h b/include/acpi/battery.h
> index c93f16dfb944..08c7e37996bf 100644
> --- a/include/acpi/battery.h
> +++ b/include/acpi/battery.h
> @@ -18,8 +18,9 @@ struct acpi_battery_hook {
> struct list_head list;
> };
>
> -void battery_hook_register(struct acpi_battery_hook *hook);
> -void battery_hook_unregister(struct acpi_battery_hook *hook);
> -int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook);
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook);
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
> +int devm_acpi_battery_hook_register(struct device *dev,
> + struct acpi_battery_hook *hook);
>
> #endif
> --
> 2.56.0
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
2026-09-30 23:19 ` Armin Wolf
2026-10-01 0:21 ` Jonathan Woithe
@ 2026-10-01 1:14 ` Derek J. Clark
2026-10-01 13:19 ` Mark Pearson
3 siblings, 0 replies; 8+ messages in thread
From: Derek J. Clark @ 2026-10-01 1:14 UTC (permalink / raw)
To: Jordan Brough, Rafael J. Wysocki, Len Brown, Corentin Chary,
Luke D. Jones, Denis Benato, Hans de Goede, Ilpo Järvinen,
Antheas Kapenekakis, Matthew Garrett, Pali Rohár,
Armin Wolf, Jonathan Woithe, Mark Pearson, Ike Panhc,
Henrique de Moraes Holschuh, Matan Ziv-Av, Nikita Kravets,
Joaquín Ignacio Aramendía, Joshua Grisham,
Jeremy Soller, System76 Product Development, Azael Avalos,
Thomas Weißschuh, Benson Leung, Guenter Roeck,
Sebastian Reichel
Cc: linux-acpi, linux-kernel, platform-driver-x86, ibm-acpi-devel,
chrome-platform, linux-pm
On September 30, 2026 3:26:33 PM PDT, Jordan Brough <jordan@brough.org> wrote:
>Rename battery_hook_register(), battery_hook_unregister() and
>devm_battery_hook_register() to acpi_battery_hook_register(),
>acpi_battery_hook_unregister() and devm_acpi_battery_hook_register(), so
>that the exported ACPI battery hook API has a consistent namespace, and
>update all in-tree callers.
>
>No functional change.
For the lenovo/wmi-other changes.
Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com>
>Signed-off-by: Jordan Brough <jordan@brough.org>
>---
> drivers/acpi/battery.c | 30 ++++++++++----------
> drivers/platform/x86/asus-wmi.c | 4 +--
> drivers/platform/x86/ayaneo-ec.c | 2 +-
> drivers/platform/x86/dell/dell-laptop.c | 4 +--
> drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
> drivers/platform/x86/fujitsu-laptop.c | 4 +--
> drivers/platform/x86/huawei-wmi.c | 4 +--
> drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +--
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +--
> drivers/platform/x86/lenovo/wmi-other.c | 4 +--
> drivers/platform/x86/lg-laptop.c | 4 +--
> drivers/platform/x86/msi-ec.c | 4 +--
> drivers/platform/x86/oxpec.c | 2 +-
> drivers/platform/x86/samsung-galaxybook.c | 3 +-
> drivers/platform/x86/samsung-laptop.c | 4 +--
> drivers/platform/x86/system76_acpi.c | 4 +--
> drivers/platform/x86/toshiba_acpi.c | 4 +--
> drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
> drivers/power/supply/cros_charge-control.c | 2 +-
> include/acpi/battery.h | 7 +++--
> 20 files changed, 50 insertions(+), 48 deletions(-)
>
>diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
>index 8599949f8786..306bb2088ca6 100644
>--- a/drivers/acpi/battery.c
>+++ b/drivers/acpi/battery.c
>@@ -821,7 +821,7 @@ static LIST_HEAD(acpi_battery_list);
> static LIST_HEAD(battery_hook_list);
> static DEFINE_MUTEX(hook_mutex);
>
>-static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
>+static void acpi_battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
>@@ -838,7 +838,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
> pr_info("hook unregistered: %s\n", hook->name);
> }
>
>-void battery_hook_unregister(struct acpi_battery_hook *hook)
>+void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
> {
> mutex_lock(&hook_mutex);
> /*
>@@ -847,13 +847,13 @@ void battery_hook_unregister(struct acpi_battery_hook *hook)
> * adding a new battery.
> */
> if (!list_empty(&hook->list))
>- battery_hook_unregister_unlocked(hook);
>+ acpi_battery_hook_unregister_unlocked(hook);
>
> mutex_unlock(&hook_mutex);
> }
>-EXPORT_SYMBOL_GPL(battery_hook_unregister);
>+EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
>
>-void battery_hook_register(struct acpi_battery_hook *hook)
>+void acpi_battery_hook_register(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
>@@ -874,7 +874,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> * hooks.
> */
> pr_err("hook failed to load: %s", hook->name);
>- battery_hook_unregister_unlocked(hook);
>+ acpi_battery_hook_unregister_unlocked(hook);
> goto end;
> }
>
>@@ -884,22 +884,22 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> end:
> mutex_unlock(&hook_mutex);
> }
>-EXPORT_SYMBOL_GPL(battery_hook_register);
>+EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
>
>-static void devm_battery_hook_unregister(void *data)
>+static void devm_acpi_battery_hook_unregister(void *data)
> {
> struct acpi_battery_hook *hook = data;
>
>- battery_hook_unregister(hook);
>+ acpi_battery_hook_unregister(hook);
> }
>
>-int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
>+int devm_acpi_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
> {
>- battery_hook_register(hook);
>+ acpi_battery_hook_register(hook);
>
>- return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
>+ return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
> }
>-EXPORT_SYMBOL_GPL(devm_battery_hook_register);
>+EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
>
> /*
> * This function gets called right after the battery sysfs
>@@ -928,7 +928,7 @@ static void battery_hook_add_battery(struct acpi_battery *battery)
> */
> pr_err("error in hook, unloading: %s",
> hook_node->name);
>- battery_hook_unregister_unlocked(hook_node);
>+ acpi_battery_hook_unregister_unlocked(hook_node);
> }
> }
> mutex_unlock(&hook_mutex);
>@@ -961,7 +961,7 @@ static void __exit battery_hook_exit(void)
> * need to remove the hooks.
> */
> list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
>- battery_hook_unregister(hook);
>+ acpi_battery_hook_unregister(hook);
> }
> mutex_destroy(&hook_mutex);
> }
>diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
>index a65090429ca7..c274f456863c 100644
>--- a/drivers/platform/x86/asus-wmi.c
>+++ b/drivers/platform/x86/asus-wmi.c
>@@ -1681,14 +1681,14 @@ static void asus_wmi_battery_init(struct asus_wmi *asus)
> asus->battery_rsoc_available = false;
> if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) {
> asus->battery_rsoc_available = true;
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
> }
> }
>
> static void asus_wmi_battery_exit(struct asus_wmi *asus)
> {
> if (asus->battery_rsoc_available)
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* LEDs ***********************************************************************/
>diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
>index 41a24e091248..3ba87bd16c9a 100644
>--- a/drivers/platform/x86/ayaneo-ec.c
>+++ b/drivers/platform/x86/ayaneo-ec.c
>@@ -493,7 +493,7 @@ static int ayaneo_ec_probe(struct platform_device *pdev)
> data->battery_hook.add_battery = ayaneo_add_battery;
> data->battery_hook.remove_battery = ayaneo_remove_battery;
> data->battery_hook.name = "Ayaneo Battery";
>- ret = devm_battery_hook_register(&pdev->dev, &data->battery_hook);
>+ ret = devm_acpi_battery_hook_register(&pdev->dev, &data->battery_hook);
> if (ret)
> return ret;
> }
>diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
>index 89e85c7f7132..cad2bd06f28a 100644
>--- a/drivers/platform/x86/dell/dell-laptop.c
>+++ b/drivers/platform/x86/dell/dell-laptop.c
>@@ -2446,13 +2446,13 @@ static void __init dell_battery_init(struct device *dev)
> battery_supported_modes = battery_get_supported_modes();
>
> if (battery_supported_modes != 0)
>- battery_hook_register(&dell_battery_hook);
>+ acpi_battery_hook_register(&dell_battery_hook);
> }
>
> static void dell_battery_exit(void)
> {
> if (battery_supported_modes != 0)
>- battery_hook_unregister(&dell_battery_hook);
>+ acpi_battery_hook_unregister(&dell_battery_hook);
> }
>
> static int __init dell_init(void)
>diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
>index f8903ced461b..6f0504d7519e 100644
>--- a/drivers/platform/x86/dell/dell-wmi-ddv.c
>+++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
>@@ -972,7 +972,7 @@ static int dell_wmi_ddv_battery_add(struct dell_wmi_ddv_data *data)
> data->eppid_attr.attr.mode = 0444;
> data->eppid_attr.show = eppid_show;
>
>- return devm_battery_hook_register(&data->wdev->dev, &data->hook);
>+ return devm_acpi_battery_hook_register(&data->wdev->dev, &data->hook);
> }
>
> static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum dell_ddv_method method)
>diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
>index ea543deef68f..96e74c4fdb29 100644
>--- a/drivers/platform/x86/fujitsu-laptop.c
>+++ b/drivers/platform/x86/fujitsu-laptop.c
>@@ -267,7 +267,7 @@ static int fujitsu_battery_charge_control_add(struct device *dev)
> return -ENODEV;
>
> priv->charge_control_supported = true;
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
>
> return 0;
> }
>@@ -277,7 +277,7 @@ static void fujitsu_battery_charge_control_remove(struct device *dev)
> struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>
> if (priv->charge_control_supported)
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* Hardware access for LCD brightness control */
>diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c
>index d6aaf14d66a5..8cc0e900e984 100644
>--- a/drivers/platform/x86/huawei-wmi.c
>+++ b/drivers/platform/x86/huawei-wmi.c
>@@ -512,7 +512,7 @@ static void huawei_wmi_battery_setup(struct device *dev)
> return;
> }
>
>- battery_hook_register(&huawei_wmi_battery_hook);
>+ acpi_battery_hook_register(&huawei_wmi_battery_hook);
> device_create_file(dev, &dev_attr_charge_control_thresholds);
> }
>
>@@ -521,7 +521,7 @@ static void huawei_wmi_battery_exit(struct device *dev)
> struct huawei_wmi *huawei = dev_get_drvdata(dev);
>
> if (huawei->battery_available) {
>- battery_hook_unregister(&huawei_wmi_battery_hook);
>+ acpi_battery_hook_unregister(&huawei_wmi_battery_hook);
> device_remove_file(dev, &dev_attr_charge_control_thresholds);
> }
> }
>diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
>index 8213524504ee..1d90d4591641 100644
>--- a/drivers/platform/x86/lenovo/ideapad-laptop.c
>+++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
>@@ -2197,8 +2197,8 @@ static int ideapad_check_features(struct ideapad_private *priv)
> priv->battery_hook.remove_battery = ideapad_battery_remove;
> priv->battery_hook.name = "Ideapad Battery Extension";
>
>- err = devm_battery_hook_register(&priv->platform_device->dev,
>- &priv->battery_hook);
>+ err = devm_acpi_battery_hook_register(&priv->platform_device->dev,
>+ &priv->battery_hook);
> if (err)
> return err;
> }
>diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>index 1661f070c571..eb5ad18855db 100644
>--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
>+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>@@ -10021,13 +10021,13 @@ static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
> battery_quirk_table,
> ARRAY_SIZE(battery_quirk_table));
>
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void tpacpi_battery_exit(void)
> {
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
> }
>
> static struct ibm_struct battery_driver_data = {
>diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
>index fbb32bf404f2..0450634ac1dd 100644
>--- a/drivers/platform/x86/lenovo/wmi-other.c
>+++ b/drivers/platform/x86/lenovo/wmi-other.c
>@@ -946,7 +946,7 @@ static void lwmi_om_psy_ext_init(struct lwmi_om_priv *priv)
> priv->battery_hook.name = "Lenovo WMI Other Battery Extension";
> priv->bh_registered = true;
>
>- battery_hook_register(&priv->battery_hook);
>+ acpi_battery_hook_register(&priv->battery_hook);
> }
>
> /**
>@@ -960,7 +960,7 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
> if (!priv->bh_registered)
> return;
>
>- battery_hook_unregister(&priv->battery_hook);
>+ acpi_battery_hook_unregister(&priv->battery_hook);
> priv->bh_registered = false;
> }
>
>diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
>index 36ad1e269443..e788671307c4 100644
>--- a/drivers/platform/x86/lg-laptop.c
>+++ b/drivers/platform/x86/lg-laptop.c
>@@ -1053,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
> if (ret)
> goto out_platform_device;
>
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
>@@ -1068,7 +1068,7 @@ static void acpi_remove(struct platform_device *pdev)
> {
> sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group);
>
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
> platform_device_unregister(pf_device);
> pf_device = NULL;
> platform_driver_unregister(&pf_driver);
>diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
>index 566dfc73cb67..cb30a1d5b546 100644
>--- a/drivers/platform/x86/msi-ec.c
>+++ b/drivers/platform/x86/msi-ec.c
>@@ -1428,13 +1428,13 @@ static int __init msi_ec_init(void)
> if (result < 0)
> return result;
>
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void __exit msi_ec_exit(void)
> {
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
> }
>
> MODULE_LICENSE("GPL");
>diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c
>index 34bb17fca148..318f194e72b5 100644
>--- a/drivers/platform/x86/oxpec.c
>+++ b/drivers/platform/x86/oxpec.c
>@@ -956,7 +956,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
> return PTR_ERR(hwdev);
>
> if (oxp_psy_ext_supported()) {
>- ret = devm_battery_hook_register(dev, &battery_hook);
>+ ret = devm_acpi_battery_hook_register(dev, &battery_hook);
> if (ret)
> return ret;
> }
>diff --git a/drivers/platform/x86/samsung-galaxybook.c b/drivers/platform/x86/samsung-galaxybook.c
>index 99f72b204a51..a4f7dbb76214 100644
>--- a/drivers/platform/x86/samsung-galaxybook.c
>+++ b/drivers/platform/x86/samsung-galaxybook.c
>@@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct samsung_galaxybook *galaxybo
> galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
> galaxybook->battery_hook.name = "Samsung Galaxy Book Battery Extension";
>
>- return devm_battery_hook_register(&galaxybook->platform->dev, &galaxybook->battery_hook);
>+ return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
>+ &galaxybook->battery_hook);
> }
>
> /*
>diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
>index 710f3d5bf84c..43fa1dc2773c 100644
>--- a/drivers/platform/x86/samsung-laptop.c
>+++ b/drivers/platform/x86/samsung-laptop.c
>@@ -1142,8 +1142,8 @@ static int __init samsung_battery_hook_init(struct samsung_laptop *samsung)
> samsung->battery_hook.add_battery = samsung_battery_add;
> samsung->battery_hook.remove_battery = samsung_battery_remove;
> samsung->battery_hook.name = "Samsung Battery Extension";
>- retval = devm_battery_hook_register(&samsung->platform_device->dev,
>- &samsung->battery_hook);
>+ retval = devm_acpi_battery_hook_register(&samsung->platform_device->dev,
>+ &samsung->battery_hook);
> }
>
> return retval;
>diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c
>index dd7b1b07c316..33968b61f0b2 100644
>--- a/drivers/platform/x86/system76_acpi.c
>+++ b/drivers/platform/x86/system76_acpi.c
>@@ -288,12 +288,12 @@ static struct acpi_battery_hook system76_battery_hook = {
>
> static void system76_battery_init(void)
> {
>- battery_hook_register(&system76_battery_hook);
>+ acpi_battery_hook_register(&system76_battery_hook);
> }
>
> static void system76_battery_exit(void)
> {
>- battery_hook_unregister(&system76_battery_hook);
>+ acpi_battery_hook_unregister(&system76_battery_hook);
> }
>
> // Get the airplane mode LED brightness
>diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
>index a0b8060836d0..4cc879bc267a 100644
>--- a/drivers/platform/x86/toshiba_acpi.c
>+++ b/drivers/platform/x86/toshiba_acpi.c
>@@ -3301,7 +3301,7 @@ static void toshiba_acpi_remove(struct platform_device *pdev)
> }
>
> if (dev->battery_charge_mode_supported)
>- battery_hook_unregister(&battery_hook);
>+ acpi_battery_hook_unregister(&battery_hook);
>
> if (toshiba_acpi)
> toshiba_acpi = NULL;
>@@ -3566,7 +3566,7 @@ static int toshiba_acpi_probe(struct platform_device *pdev)
> * set, this must be done after toshiba_acpi is assigned.
> */
> if (dev->battery_charge_mode_supported)
>- battery_hook_register(&battery_hook);
>+ acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
>diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
>index 7a2eeaec4c96..d76695c2c765 100644
>--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
>+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
>@@ -2165,7 +2165,7 @@ static int uniwill_battery_init(struct uniwill_data *data)
> data->hook.add_battery = uniwill_add_battery;
> data->hook.remove_battery = uniwill_remove_battery;
>
>- return devm_battery_hook_register(data->dev, &data->hook);
>+ return devm_acpi_battery_hook_register(data->dev, &data->hook);
> }
>
> static int uniwill_notifier_call(struct notifier_block *nb, unsigned long action, void *dummy)
>diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
>index e0f168624807..1901bbcffd73 100644
>--- a/drivers/power/supply/cros_charge-control.c
>+++ b/drivers/power/supply/cros_charge-control.c
>@@ -315,7 +315,7 @@ static int cros_chctl_probe(struct platform_device *pdev)
> if (ret < 0)
> return ret;
>
>- return devm_battery_hook_register(dev, &priv->battery_hook);
>+ return devm_acpi_battery_hook_register(dev, &priv->battery_hook);
> }
>
> static const struct platform_device_id cros_chctl_id[] = {
>diff --git a/include/acpi/battery.h b/include/acpi/battery.h
>index c93f16dfb944..08c7e37996bf 100644
>--- a/include/acpi/battery.h
>+++ b/include/acpi/battery.h
>@@ -18,8 +18,9 @@ struct acpi_battery_hook {
> struct list_head list;
> };
>
>-void battery_hook_register(struct acpi_battery_hook *hook);
>-void battery_hook_unregister(struct acpi_battery_hook *hook);
>-int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook);
>+void acpi_battery_hook_register(struct acpi_battery_hook *hook);
>+void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
>+int devm_acpi_battery_hook_register(struct device *dev,
>+ struct acpi_battery_hook *hook);
>
> #endif
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
` (2 preceding siblings ...)
2026-10-01 1:14 ` Derek J. Clark
@ 2026-10-01 13:19 ` Mark Pearson
3 siblings, 0 replies; 8+ messages in thread
From: Mark Pearson @ 2026-10-01 13:19 UTC (permalink / raw)
To: Jordan Brough, Rafael J. Wysocki, Len Brown, Corentin Chary,
Luke D . Jones, Denis Benato, Hans de Goede, Ilpo Järvinen,
Antheas Kapenekakis, Matthew Garrett, Pali Rohár,
Armin Wolf, Jonathan Woithe, Derek J . Clark, Ike Panhc,
Henrique de Moraes Holschuh, Matan Ziv-Av, Nikita Kravets,
Joaquín Ignacio Aramendía, Joshua Grisham,
Jeremy Soller, System76 Product Development, Azael Avalos,
Thomas Weißschuh, Benson Leung, Guenter Roeck,
Sebastian Reichel
Cc: linux-acpi, linux-kernel, platform-driver-x86, ibm-acpi-devel,
chrome-platform, linux-pm
On Wed, Sep 30, 2026, at 6:26 PM, Jordan Brough wrote:
> Rename battery_hook_register(), battery_hook_unregister() and
> devm_battery_hook_register() to acpi_battery_hook_register(),
> acpi_battery_hook_unregister() and devm_acpi_battery_hook_register(), so
> that the exported ACPI battery hook API has a consistent namespace, and
> update all in-tree callers.
>
> No functional change.
>
> Signed-off-by: Jordan Brough <jordan@brough.org>
> ---
> drivers/acpi/battery.c | 30 ++++++++++----------
> drivers/platform/x86/asus-wmi.c | 4 +--
> drivers/platform/x86/ayaneo-ec.c | 2 +-
> drivers/platform/x86/dell/dell-laptop.c | 4 +--
> drivers/platform/x86/dell/dell-wmi-ddv.c | 2 +-
> drivers/platform/x86/fujitsu-laptop.c | 4 +--
> drivers/platform/x86/huawei-wmi.c | 4 +--
> drivers/platform/x86/lenovo/ideapad-laptop.c | 4 +--
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +--
> drivers/platform/x86/lenovo/wmi-other.c | 4 +--
> drivers/platform/x86/lg-laptop.c | 4 +--
> drivers/platform/x86/msi-ec.c | 4 +--
> drivers/platform/x86/oxpec.c | 2 +-
> drivers/platform/x86/samsung-galaxybook.c | 3 +-
> drivers/platform/x86/samsung-laptop.c | 4 +--
> drivers/platform/x86/system76_acpi.c | 4 +--
> drivers/platform/x86/toshiba_acpi.c | 4 +--
> drivers/platform/x86/uniwill/uniwill-acpi.c | 2 +-
> drivers/power/supply/cros_charge-control.c | 2 +-
> include/acpi/battery.h | 7 +++--
> 20 files changed, 50 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 8599949f8786..306bb2088ca6 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -821,7 +821,7 @@ static LIST_HEAD(acpi_battery_list);
> static LIST_HEAD(battery_hook_list);
> static DEFINE_MUTEX(hook_mutex);
>
> -static void battery_hook_unregister_unlocked(struct acpi_battery_hook
> *hook)
> +static void acpi_battery_hook_unregister_unlocked(struct
> acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -838,7 +838,7 @@ static void battery_hook_unregister_unlocked(struct
> acpi_battery_hook *hook)
> pr_info("hook unregistered: %s\n", hook->name);
> }
>
> -void battery_hook_unregister(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook)
> {
> mutex_lock(&hook_mutex);
> /*
> @@ -847,13 +847,13 @@ void battery_hook_unregister(struct
> acpi_battery_hook *hook)
> * adding a new battery.
> */
> if (!list_empty(&hook->list))
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
>
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_unregister);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_unregister);
>
> -void battery_hook_register(struct acpi_battery_hook *hook)
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook)
> {
> struct acpi_battery *battery;
>
> @@ -874,7 +874,7 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> * hooks.
> */
> pr_err("hook failed to load: %s", hook->name);
> - battery_hook_unregister_unlocked(hook);
> + acpi_battery_hook_unregister_unlocked(hook);
> goto end;
> }
>
> @@ -884,22 +884,22 @@ void battery_hook_register(struct acpi_battery_hook *hook)
> end:
> mutex_unlock(&hook_mutex);
> }
> -EXPORT_SYMBOL_GPL(battery_hook_register);
> +EXPORT_SYMBOL_GPL(acpi_battery_hook_register);
>
> -static void devm_battery_hook_unregister(void *data)
> +static void devm_acpi_battery_hook_unregister(void *data)
> {
> struct acpi_battery_hook *hook = data;
>
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
>
> -int devm_battery_hook_register(struct device *dev, struct
> acpi_battery_hook *hook)
> +int devm_acpi_battery_hook_register(struct device *dev, struct
> acpi_battery_hook *hook)
> {
> - battery_hook_register(hook);
> + acpi_battery_hook_register(hook);
>
> - return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
> + return devm_add_action_or_reset(dev, devm_acpi_battery_hook_unregister, hook);
> }
> -EXPORT_SYMBOL_GPL(devm_battery_hook_register);
> +EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);
>
> /*
> * This function gets called right after the battery sysfs
> @@ -928,7 +928,7 @@ static void battery_hook_add_battery(struct
> acpi_battery *battery)
> */
> pr_err("error in hook, unloading: %s",
> hook_node->name);
> - battery_hook_unregister_unlocked(hook_node);
> + acpi_battery_hook_unregister_unlocked(hook_node);
> }
> }
> mutex_unlock(&hook_mutex);
> @@ -961,7 +961,7 @@ static void __exit battery_hook_exit(void)
> * need to remove the hooks.
> */
> list_for_each_entry_safe(hook, ptr, &battery_hook_list, list) {
> - battery_hook_unregister(hook);
> + acpi_battery_hook_unregister(hook);
> }
> mutex_destroy(&hook_mutex);
> }
> diff --git a/drivers/platform/x86/asus-wmi.c
> b/drivers/platform/x86/asus-wmi.c
> index a65090429ca7..c274f456863c 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -1681,14 +1681,14 @@ static void asus_wmi_battery_init(struct
> asus_wmi *asus)
> asus->battery_rsoc_available = false;
> if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_RSOC)) {
> asus->battery_rsoc_available = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> }
> }
>
> static void asus_wmi_battery_exit(struct asus_wmi *asus)
> {
> if (asus->battery_rsoc_available)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* LEDs
> ***********************************************************************/
> diff --git a/drivers/platform/x86/ayaneo-ec.c
> b/drivers/platform/x86/ayaneo-ec.c
> index 41a24e091248..3ba87bd16c9a 100644
> --- a/drivers/platform/x86/ayaneo-ec.c
> +++ b/drivers/platform/x86/ayaneo-ec.c
> @@ -493,7 +493,7 @@ static int ayaneo_ec_probe(struct platform_device
> *pdev)
> data->battery_hook.add_battery = ayaneo_add_battery;
> data->battery_hook.remove_battery = ayaneo_remove_battery;
> data->battery_hook.name = "Ayaneo Battery";
> - ret = devm_battery_hook_register(&pdev->dev, &data->battery_hook);
> + ret = devm_acpi_battery_hook_register(&pdev->dev,
> &data->battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/dell/dell-laptop.c
> b/drivers/platform/x86/dell/dell-laptop.c
> index 89e85c7f7132..cad2bd06f28a 100644
> --- a/drivers/platform/x86/dell/dell-laptop.c
> +++ b/drivers/platform/x86/dell/dell-laptop.c
> @@ -2446,13 +2446,13 @@ static void __init dell_battery_init(struct
> device *dev)
> battery_supported_modes = battery_get_supported_modes();
>
> if (battery_supported_modes != 0)
> - battery_hook_register(&dell_battery_hook);
> + acpi_battery_hook_register(&dell_battery_hook);
> }
>
> static void dell_battery_exit(void)
> {
> if (battery_supported_modes != 0)
> - battery_hook_unregister(&dell_battery_hook);
> + acpi_battery_hook_unregister(&dell_battery_hook);
> }
>
> static int __init dell_init(void)
> diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c
> b/drivers/platform/x86/dell/dell-wmi-ddv.c
> index f8903ced461b..6f0504d7519e 100644
> --- a/drivers/platform/x86/dell/dell-wmi-ddv.c
> +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
> @@ -972,7 +972,7 @@ static int dell_wmi_ddv_battery_add(struct
> dell_wmi_ddv_data *data)
> data->eppid_attr.attr.mode = 0444;
> data->eppid_attr.show = eppid_show;
>
> - return devm_battery_hook_register(&data->wdev->dev, &data->hook);
> + return devm_acpi_battery_hook_register(&data->wdev->dev, &data->hook);
> }
>
> static int dell_wmi_ddv_buffer_read(struct seq_file *seq, enum
> dell_ddv_method method)
> diff --git a/drivers/platform/x86/fujitsu-laptop.c
> b/drivers/platform/x86/fujitsu-laptop.c
> index ea543deef68f..96e74c4fdb29 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -267,7 +267,7 @@ static int
> fujitsu_battery_charge_control_add(struct device *dev)
> return -ENODEV;
>
> priv->charge_control_supported = true;
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
> }
> @@ -277,7 +277,7 @@ static void
> fujitsu_battery_charge_control_remove(struct device *dev)
> struct fujitsu_laptop *priv = dev_get_drvdata(dev);
>
> if (priv->charge_control_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> /* Hardware access for LCD brightness control */
> diff --git a/drivers/platform/x86/huawei-wmi.c
> b/drivers/platform/x86/huawei-wmi.c
> index d6aaf14d66a5..8cc0e900e984 100644
> --- a/drivers/platform/x86/huawei-wmi.c
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -512,7 +512,7 @@ static void huawei_wmi_battery_setup(struct device
> *dev)
> return;
> }
>
> - battery_hook_register(&huawei_wmi_battery_hook);
> + acpi_battery_hook_register(&huawei_wmi_battery_hook);
> device_create_file(dev, &dev_attr_charge_control_thresholds);
> }
>
> @@ -521,7 +521,7 @@ static void huawei_wmi_battery_exit(struct device *dev)
> struct huawei_wmi *huawei = dev_get_drvdata(dev);
>
> if (huawei->battery_available) {
> - battery_hook_unregister(&huawei_wmi_battery_hook);
> + acpi_battery_hook_unregister(&huawei_wmi_battery_hook);
> device_remove_file(dev, &dev_attr_charge_control_thresholds);
> }
> }
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c
> b/drivers/platform/x86/lenovo/ideapad-laptop.c
> index 8213524504ee..1d90d4591641 100644
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
> @@ -2197,8 +2197,8 @@ static int ideapad_check_features(struct
> ideapad_private *priv)
> priv->battery_hook.remove_battery = ideapad_battery_remove;
> priv->battery_hook.name = "Ideapad Battery Extension";
>
> - err = devm_battery_hook_register(&priv->platform_device->dev,
> - &priv->battery_hook);
> + err = devm_acpi_battery_hook_register(&priv->platform_device->dev,
> + &priv->battery_hook);
> if (err)
> return err;
> }
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 1661f070c571..eb5ad18855db 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -10021,13 +10021,13 @@ static int __init tpacpi_battery_init(struct
> ibm_init_struct *ibm)
> battery_quirk_table,
> ARRAY_SIZE(battery_quirk_table));
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void tpacpi_battery_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> static struct ibm_struct battery_driver_data = {
> diff --git a/drivers/platform/x86/lenovo/wmi-other.c
> b/drivers/platform/x86/lenovo/wmi-other.c
> index fbb32bf404f2..0450634ac1dd 100644
> --- a/drivers/platform/x86/lenovo/wmi-other.c
> +++ b/drivers/platform/x86/lenovo/wmi-other.c
> @@ -946,7 +946,7 @@ static void lwmi_om_psy_ext_init(struct
> lwmi_om_priv *priv)
> priv->battery_hook.name = "Lenovo WMI Other Battery Extension";
> priv->bh_registered = true;
>
> - battery_hook_register(&priv->battery_hook);
> + acpi_battery_hook_register(&priv->battery_hook);
> }
>
> /**
> @@ -960,7 +960,7 @@ static void lwmi_om_psy_remove(struct lwmi_om_priv *priv)
> if (!priv->bh_registered)
> return;
>
> - battery_hook_unregister(&priv->battery_hook);
> + acpi_battery_hook_unregister(&priv->battery_hook);
> priv->bh_registered = false;
> }
>
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index 36ad1e269443..e788671307c4 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -1053,7 +1053,7 @@ static int acpi_probe(struct platform_device *pdev)
> if (ret)
> goto out_platform_device;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> @@ -1068,7 +1068,7 @@ static void acpi_remove(struct platform_device *pdev)
> {
> sysfs_remove_group(&pf_device->dev.kobj, &dev_attribute_group);
>
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> platform_device_unregister(pf_device);
> pf_device = NULL;
> platform_driver_unregister(&pf_driver);
> diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c
> index 566dfc73cb67..cb30a1d5b546 100644
> --- a/drivers/platform/x86/msi-ec.c
> +++ b/drivers/platform/x86/msi-ec.c
> @@ -1428,13 +1428,13 @@ static int __init msi_ec_init(void)
> if (result < 0)
> return result;
>
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
> return 0;
> }
>
> static void __exit msi_ec_exit(void)
> {
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
> }
>
> MODULE_LICENSE("GPL");
> diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c
> index 34bb17fca148..318f194e72b5 100644
> --- a/drivers/platform/x86/oxpec.c
> +++ b/drivers/platform/x86/oxpec.c
> @@ -956,7 +956,7 @@ static int oxp_platform_probe(struct platform_device *pdev)
> return PTR_ERR(hwdev);
>
> if (oxp_psy_ext_supported()) {
> - ret = devm_battery_hook_register(dev, &battery_hook);
> + ret = devm_acpi_battery_hook_register(dev, &battery_hook);
> if (ret)
> return ret;
> }
> diff --git a/drivers/platform/x86/samsung-galaxybook.c
> b/drivers/platform/x86/samsung-galaxybook.c
> index 99f72b204a51..a4f7dbb76214 100644
> --- a/drivers/platform/x86/samsung-galaxybook.c
> +++ b/drivers/platform/x86/samsung-galaxybook.c
> @@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct
> samsung_galaxybook *galaxybo
> galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
> galaxybook->battery_hook.name = "Samsung Galaxy Book Battery
> Extension";
>
> - return devm_battery_hook_register(&galaxybook->platform->dev,
> &galaxybook->battery_hook);
> + return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
> + &galaxybook->battery_hook);
> }
>
> /*
> diff --git a/drivers/platform/x86/samsung-laptop.c
> b/drivers/platform/x86/samsung-laptop.c
> index 710f3d5bf84c..43fa1dc2773c 100644
> --- a/drivers/platform/x86/samsung-laptop.c
> +++ b/drivers/platform/x86/samsung-laptop.c
> @@ -1142,8 +1142,8 @@ static int __init
> samsung_battery_hook_init(struct samsung_laptop *samsung)
> samsung->battery_hook.add_battery = samsung_battery_add;
> samsung->battery_hook.remove_battery = samsung_battery_remove;
> samsung->battery_hook.name = "Samsung Battery Extension";
> - retval = devm_battery_hook_register(&samsung->platform_device->dev,
> - &samsung->battery_hook);
> + retval =
> devm_acpi_battery_hook_register(&samsung->platform_device->dev,
> + &samsung->battery_hook);
> }
>
> return retval;
> diff --git a/drivers/platform/x86/system76_acpi.c
> b/drivers/platform/x86/system76_acpi.c
> index dd7b1b07c316..33968b61f0b2 100644
> --- a/drivers/platform/x86/system76_acpi.c
> +++ b/drivers/platform/x86/system76_acpi.c
> @@ -288,12 +288,12 @@ static struct acpi_battery_hook
> system76_battery_hook = {
>
> static void system76_battery_init(void)
> {
> - battery_hook_register(&system76_battery_hook);
> + acpi_battery_hook_register(&system76_battery_hook);
> }
>
> static void system76_battery_exit(void)
> {
> - battery_hook_unregister(&system76_battery_hook);
> + acpi_battery_hook_unregister(&system76_battery_hook);
> }
>
> // Get the airplane mode LED brightness
> diff --git a/drivers/platform/x86/toshiba_acpi.c
> b/drivers/platform/x86/toshiba_acpi.c
> index a0b8060836d0..4cc879bc267a 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -3301,7 +3301,7 @@ static void toshiba_acpi_remove(struct
> platform_device *pdev)
> }
>
> if (dev->battery_charge_mode_supported)
> - battery_hook_unregister(&battery_hook);
> + acpi_battery_hook_unregister(&battery_hook);
>
> if (toshiba_acpi)
> toshiba_acpi = NULL;
> @@ -3566,7 +3566,7 @@ static int toshiba_acpi_probe(struct
> platform_device *pdev)
> * set, this must be done after toshiba_acpi is assigned.
> */
> if (dev->battery_charge_mode_supported)
> - battery_hook_register(&battery_hook);
> + acpi_battery_hook_register(&battery_hook);
>
> return 0;
>
> diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c
> b/drivers/platform/x86/uniwill/uniwill-acpi.c
> index 7a2eeaec4c96..d76695c2c765 100644
> --- a/drivers/platform/x86/uniwill/uniwill-acpi.c
> +++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
> @@ -2165,7 +2165,7 @@ static int uniwill_battery_init(struct
> uniwill_data *data)
> data->hook.add_battery = uniwill_add_battery;
> data->hook.remove_battery = uniwill_remove_battery;
>
> - return devm_battery_hook_register(data->dev, &data->hook);
> + return devm_acpi_battery_hook_register(data->dev, &data->hook);
> }
>
> static int uniwill_notifier_call(struct notifier_block *nb, unsigned
> long action, void *dummy)
> diff --git a/drivers/power/supply/cros_charge-control.c
> b/drivers/power/supply/cros_charge-control.c
> index e0f168624807..1901bbcffd73 100644
> --- a/drivers/power/supply/cros_charge-control.c
> +++ b/drivers/power/supply/cros_charge-control.c
> @@ -315,7 +315,7 @@ static int cros_chctl_probe(struct platform_device
> *pdev)
> if (ret < 0)
> return ret;
>
> - return devm_battery_hook_register(dev, &priv->battery_hook);
> + return devm_acpi_battery_hook_register(dev, &priv->battery_hook);
> }
>
> static const struct platform_device_id cros_chctl_id[] = {
> diff --git a/include/acpi/battery.h b/include/acpi/battery.h
> index c93f16dfb944..08c7e37996bf 100644
> --- a/include/acpi/battery.h
> +++ b/include/acpi/battery.h
> @@ -18,8 +18,9 @@ struct acpi_battery_hook {
> struct list_head list;
> };
>
> -void battery_hook_register(struct acpi_battery_hook *hook);
> -void battery_hook_unregister(struct acpi_battery_hook *hook);
> -int devm_battery_hook_register(struct device *dev, struct
> acpi_battery_hook *hook);
> +void acpi_battery_hook_register(struct acpi_battery_hook *hook);
> +void acpi_battery_hook_unregister(struct acpi_battery_hook *hook);
> +int devm_acpi_battery_hook_register(struct device *dev,
> + struct acpi_battery_hook *hook);
>
> #endif
> --
> 2.56.0
For the lenovo/* changes:
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-10-01 13:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 22:26 [PATCH v3 0/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
2026-09-30 22:26 ` [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API Jordan Brough
2026-09-30 23:19 ` Armin Wolf
2026-10-01 0:21 ` Jonathan Woithe
2026-10-01 1:14 ` Derek J. Clark
2026-10-01 13:19 ` Mark Pearson
2026-09-30 22:26 ` [PATCH v3 2/3] ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries Jordan Brough
2026-09-30 22:26 ` [PATCH v3 3/3] hwmon: (applesmc) add charge_control_end_threshold support Jordan Brough
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®