Skip to contentSkip to conversation

hwmon: (applesmc) add charge_control_end_threshold support

PATCH In review Jordan Brough 11 participants 18 messages Sep 30 – Nov 10

Subsystems (24)
lore
Share & tools
lore
#0 lore raw

v3 cover hwmon: (applesmc) add charge_control_end_threshold support

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.

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

Signature · 1 line
2.56.0
#1 lore raw

PATCH v3 1/3 ACPI: battery: add acpi_ prefix to the battery hook API

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.

---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
Signature · 1 line
2.56.0
maintainer Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Am 01.10.26 um 00:26 schrieb Jordan Brough:

Quoted 7 lines

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:

Quoted 456 lines
---
  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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
  }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
  	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
  	}
  }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
  		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
  }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
  	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
  }
 
  /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
maintainer
#3 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough
Quoted 7 lines · 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 fujitsu-laptop changes:

Quoted 458 lines
---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
Signature · 1 line
2.56.0
#4 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Quoted 8 lines · Jonathan Woithe
Quoted 6 lines · 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.

Quoted 5 lines
Quoted 1 line

No functional change.

For the fujitsu-laptop changes:

This should be Acked-by, no?

Because you are not the author of anything in the patch nor a maintainer forwarding it to me.

Quoted 460 lines
Quoted 457 lines
---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
      }
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
      }
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
              }
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
      }
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -4
index c93f16dfb944..08c7e37996bf 100644
@@ -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
--
Quoted 1 line

2.56.0

--

maintainer Acked-by
#5 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Quoted 11 lines · Rafael J. Wysocki (Intel)
Quoted 10 lines · Jonathan Woithe
Quoted 7 lines · 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.

Quoted 8 lines
Quoted 3 lines

For the fujitsu-laptop changes:

This should be Acked-by, no?

Because you are not the author of anything in the patch nor a maintainer forwarding it to me.

Yes, good point. Sorry, I must have had a brain fade.

For the fujitsu-laptop changes:

Regards
jonathan

Quoted 460 lines
Quoted 460 lines
Quoted 457 lines
---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
      }
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
      }
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
              }
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
      }
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -4
index c93f16dfb944..08c7e37996bf 100644
@@ -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
--
Quoted 1 line

2.56.0

--

maintainer Reviewed-by on v3 1/3
#6 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough
Quoted 7 lines · 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 lenovo/wmi-other changes.

Quoted 456 lines

---

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(-)
drivers/acpi/battery.c +6 -6
index 8599949f8786..306bb2088ca6 100644
@@ -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);
}
drivers/acpi/battery.c +2 -2
-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;
drivers/acpi/battery.c +1 -1
-	battery_hook_unregister(hook);
+	acpi_battery_hook_unregister(hook);

}

drivers/acpi/battery.c +1 -1
-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)

{

drivers/acpi/battery.c +2 -2
-	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);

}

drivers/acpi/battery.c +1 -1
-EXPORT_SYMBOL_GPL(devm_battery_hook_register);
+EXPORT_SYMBOL_GPL(devm_acpi_battery_hook_register);

/*
* This function gets called right after the battery sysfs

drivers/acpi/battery.c +2 -2
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
maintainer Reviewed-by on v3 1/3
#7 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough
Quoted 510 lines · 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.

---
 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(-)
drivers/acpi/battery.c +1 -1
index 8599949f8786..306bb2088ca6 100644
@@ -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)
 {
drivers/acpi/battery.c +1 -1
 	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);
drivers/acpi/battery.c +11 -11
 	/*
@@ -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

drivers/acpi/battery.c +1 -1
@@ -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);
 		}
 	}
drivers/acpi/battery.c +1 -1
 	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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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
***********************************************************************/

drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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)
drivers/platform/x86/ayaneo-ec.c +0 -0
 			return ret;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)

drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)

drivers/platform/x86/fujitsu-laptop.c +1 -1
index ea543deef68f..96e74c4fdb29 100644
@@ -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;

}

drivers/platform/x86/fujitsu-laptop.c +1 -1
@@ -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 */

drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
drivers/platform/x86/lenovo/ideapad-laptop.c +0 -0
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {

drivers/platform/x86/lenovo/wmi-other.c +1 -1
index fbb32bf404f2..0450634ac1dd 100644
@@ -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);
 }
 

/**

drivers/platform/x86/lenovo/wmi-other.c +1 -1
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +0 -0
index 99f72b204a51..a4f7dbb76214 100644
@@ -549,7 +549,8 @@ static int galaxybook_battery_threshold_init(struct 

samsung_galaxybook *galaxybo

drivers/platform/x86/samsung-galaxybook.c +0 -0
 	galaxybook->battery_hook.remove_battery = galaxybook_battery_remove;
 	galaxybook->battery_hook.name = "Samsung Galaxy Book Battery 

Extension";

drivers/platform/x86/samsung-galaxybook.c +0 -1
-	return devm_battery_hook_register(&galaxybook->platform->dev, 

&galaxybook->battery_hook);

drivers/platform/x86/samsung-galaxybook.c +2 -0
+	return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
+					       &galaxybook->battery_hook);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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);
 	}
drivers/platform/x86/samsung-laptop.c +0 -0
 	return retval;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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

drivers/platform/x86/toshiba_acpi.c +1 -1
index a0b8060836d0..4cc879bc267a 100644
@@ -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)
drivers/platform/x86/toshiba_acpi.c +1 -1
 		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;
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)

drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {

include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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);
 
Quoted 3 lines

#endif

Signature · 1 line
2.56.0

For the lenovo/* changes:

Mark

maintainer Reviewed-by
#8 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Quoted 10 lines · Mark Pearson
Quoted 8 lines · 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 ayaneo ec and oxpec

Quoted 512 lines
Quoted 502 lines
---
 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(-)
drivers/acpi/battery.c +1 -1
index 8599949f8786..306bb2088ca6 100644
@@ -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;
drivers/acpi/battery.c +1 -1
@@ -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);
      /*
drivers/acpi/battery.c +11 -11
@@ -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

drivers/acpi/battery.c +1 -1
@@ -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);
drivers/acpi/battery.c +1 -1
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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
***********************************************************************/

drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
      }
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)

drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)

drivers/platform/x86/fujitsu-laptop.c +1 -1
index ea543deef68f..96e74c4fdb29 100644
@@ -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;

}

drivers/platform/x86/fujitsu-laptop.c +1 -1
@@ -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 */

drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
      }
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
              }
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {

drivers/platform/x86/lenovo/wmi-other.c +1 -1
index fbb32bf404f2..0450634ac1dd 100644
@@ -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);
 }
 

/**

drivers/platform/x86/lenovo/wmi-other.c +1 -1
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
      }
drivers/platform/x86/samsung-galaxybook.c +0 -0
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);

drivers/platform/x86/samsung-galaxybook.c +2 -0
+     return devm_acpi_battery_hook_register(&galaxybook->platform->dev,
+                                            &galaxybook->battery_hook);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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

drivers/platform/x86/toshiba_acpi.c +1 -1
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
drivers/platform/x86/toshiba_acpi.c +1 -1
@@ -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;
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)

drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {

include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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);
 
Quoted 3 lines

#endif
--
2.56.0

For the lenovo/* changes:

Mark

Reviewed-by on v3 1/3
#9 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough

Hi Jordan,

Quoted 9 lines · 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 ideapad-laptop changes:

Thanks,
Rong

Quoted 455 lines
---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
Acked-by on v3 1/3
#10 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough

Hi,

Quoted 23 lines · 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.

---
 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 +-
Quoted 8 lines
 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(-)

I expect this to be merged via other tree:

Greetings,

-- Sebastian

maintainer Acked-by on v3 1/3
#11 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

In reply to Jordan Brough
Quoted 9 lines · 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.

With one known caveat! There's c72dd9994952 ("platform/x86: add Acer battery control driver") in the pdx86 tree so if Rafael takes this like he proposed in his reply to patch 2, that needs to be handled during merge.

Signature · 1 line
 i.
Quoted 456 lines
---
 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(-)
drivers/acpi/battery.c +15 -15
index 8599949f8786..306bb2088ca6 100644
@@ -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);
 }
drivers/platform/x86/asus-wmi.c +2 -2
index a65090429ca7..c274f456863c 100644
@@ -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 ***********************************************************************/
drivers/platform/x86/ayaneo-ec.c +1 -1
index 41a24e091248..3ba87bd16c9a 100644
@@ -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;
 	}
drivers/platform/x86/dell/dell-laptop.c +2 -2
index 89e85c7f7132..cad2bd06f28a 100644
@@ -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)
drivers/platform/x86/dell/dell-wmi-ddv.c +1 -1
index f8903ced461b..6f0504d7519e 100644
@@ -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)
drivers/platform/x86/fujitsu-laptop.c +2 -2
index ea543deef68f..96e74c4fdb29 100644
@@ -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 */
drivers/platform/x86/huawei-wmi.c +2 -2
index d6aaf14d66a5..8cc0e900e984 100644
@@ -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);
 	}
 }
drivers/platform/x86/lenovo/ideapad-laptop.c +2 -2
index 8213524504ee..1d90d4591641 100644
@@ -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;
 		}
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -2
index 1661f070c571..eb5ad18855db 100644
@@ -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 = {
drivers/platform/x86/lenovo/wmi-other.c +2 -2
index fbb32bf404f2..0450634ac1dd 100644
@@ -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;
 }
 
drivers/platform/x86/lg-laptop.c +2 -2
index 36ad1e269443..e788671307c4 100644
@@ -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);
drivers/platform/x86/msi-ec.c +2 -2
index 566dfc73cb67..cb30a1d5b546 100644
@@ -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");
drivers/platform/x86/oxpec.c +1 -1
index 34bb17fca148..318f194e72b5 100644
@@ -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;
 	}
drivers/platform/x86/samsung-galaxybook.c +2 -1
index 99f72b204a51..a4f7dbb76214 100644
@@ -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);
 }
 
 /*
drivers/platform/x86/samsung-laptop.c +2 -2
index 710f3d5bf84c..43fa1dc2773c 100644
@@ -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;
drivers/platform/x86/system76_acpi.c +2 -2
index dd7b1b07c316..33968b61f0b2 100644
@@ -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
drivers/platform/x86/toshiba_acpi.c +2 -2
index a0b8060836d0..4cc879bc267a 100644
@@ -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;
 
drivers/platform/x86/uniwill/uniwill-acpi.c +1 -1
index 7a2eeaec4c96..d76695c2c765 100644
@@ -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)
drivers/power/supply/cros_charge-control.c +1 -1
index e0f168624807..1901bbcffd73 100644
@@ -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[] = {
include/acpi/battery.h +4 -3
index c93f16dfb944..08c7e37996bf 100644
@@ -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
#12 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Quoted 11 lines · Ilpo Järvinen
Quoted 8 lines · 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.

Quoted 7 lines
Quoted 1 line

With one known caveat! There's c72dd9994952 ("platform/x86: add Acer battery control driver") in the pdx86 tree so if Rafael takes this like he proposed in his reply to patch 2, that needs to be handled during merge.

Well, I haven't applied it yet, so no worries.

It's in my 7.5 queue ATM.

#13 lore raw

Re: [PATCH v3 1/3] ACPI: battery: add acpi_ prefix to the battery hook API

Quoted 18 lines · Rafael J. Wysocki (Intel)
Quoted 15 lines · Ilpo Järvinen
Quoted 9 lines · 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.

Quoted 7 lines
Quoted 3 lines

With one known caveat! There's c72dd9994952 ("platform/x86: add Acer battery control driver") in the pdx86 tree so if Rafael takes this like he proposed in his reply to patch 2, that needs to be handled during merge.

Well, I haven't applied it yet, so no worries.

It's in my 7.5 queue ATM.

Patches [1-2/3] from the series applied as 7.5 material, thanks!

#14 lore raw

PATCH v3 2/3 ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries

In reply to Jordan Brough

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.

---
 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
drivers/acpi/Kconfig +5 -0
index f165d14cf61a..d0278f13e96f 100644
@@ -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
drivers/acpi/Makefile +1 -0
index d1b0affb844f..eb744dc81d3f 100644
@@ -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
drivers/acpi/battery.c +4 -162

202 lines not on this page · raw message

drivers/acpi/battery_hooks.c new file +159 -0

159 lines not on this page · raw message

drivers/acpi/sbs.c +7 -1
index f10bbf13c242..f80a6294953a 100644
@@ -36,6 +36,7 @@
 MODULE_AUTHOR("Alexey Starikovskiy <[email protected]>");
 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)
include/acpi/battery.h +9 -0
index 08c7e37996bf..6360f102a4e8 100644
@@ -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
Signature · 1 line
2.56.0
#15 lore raw

Re: [PATCH v3 2/3] ACPI: battery: add unified battery hook mechanism for ACPI and SBS batteries

Quoted 11 lines · Jordan Brough

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.

Quoted 7 lines

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.

I can apply this along with the [1/3], but the last patch will need to go through the hwmon tree. Also please note that Sashiko is complaining about that patch:

https://sashiko.dev/#/patchset/20260930222650.1883805-1-jordan%40brough.org

My suggestion would be to let the first two patches in the series go into 7.4 and do the last one properly later.

Please let me know what you think.

Quoted 491 lines
---
 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
drivers/acpi/Kconfig +5 -0
index f165d14cf61a..d0278f13e96f 100644
@@ -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
drivers/acpi/Makefile +1 -0
index d1b0affb844f..eb744dc81d3f 100644
@@ -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
drivers/acpi/battery.c +4 -162
index 306bb2088ca6..0d74f998eae6 100644
@@ -54,6 +54,7 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_AUTHOR("Alexey Starikovskiy <[email protected]>");
 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);
drivers/acpi/battery_hooks.c new file +159 -0
new file mode 100644
index 000000000000..ca3f9876cb09
@@ -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");
drivers/acpi/sbs.c +7 -1
index f10bbf13c242..f80a6294953a 100644
@@ -36,6 +36,7 @@
 MODULE_AUTHOR("Alexey Starikovskiy <[email protected]>");
 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)
include/acpi/battery.h +9 -1
index 08c7e37996bf..6360f102a4e8 100644
@@ -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

#16 lore raw

PATCH v3 3/3 hwmon: (applesmc) add charge_control_end_threshold support

In reply to Jordan Brough

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

---
 drivers/hwmon/Kconfig    |   1 +
 drivers/hwmon/applesmc.c | 146 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 147 insertions(+)
drivers/hwmon/Kconfig +1 -0
index fecff8610ea8..d627b4cf11e5 100644
@@ -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
drivers/hwmon/applesmc.c +146 -0

188 lines not on this page · raw message

Signature · 1 line
2.56.0
#17 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] hwmon: applesmc implements secondary power supply feature natively instead of using auxiliary…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] hwmon: applesmc implements secondary power supply feature natively instead of using auxiliary device
- [Medium] hwmon: applesmc uses custom mutex instead of hwmon_lock() for external attributes --

commit 7f74cc774d21a32964e467d3d8da2004ccb22a1e
Author: Jordan Brough <[email protected]>

hwmon: (applesmc) add charge_control_end_threshold support

This commit exposes the MacBook battery charge limit (BCLM) as charge_control_end_threshold through the power_supply extension API. It attaches to the battery with ACPI battery hooks and serializes writes with a newly introduced mutex.

Quoted 4 lines
drivers/hwmon/applesmc.c +0 -0
index d0baa10502f7d..b6d9ca3027308 100644

[ ... ]

drivers/hwmon/applesmc.c static struct platform_driver applesmc_driver = { · line 751

Quoted 5 lines
drivers/hwmon/applesmc.c +1 -0
@@ -724,6 +748,120 @@ static struct platform_driver applesmc_driver = {
 	},
 };
 
+static DEFINE_MUTEX(applesmc_bat_lock);

[Severity: Medium]
Does this custom lock violate the hwmon subsystem locking guidelines?

The guidelines mandate that drivers use hwmon_lock() and hwmon_unlock() for serializing attributes registered by any means other than the info parameter of hwmon_device_register_with_info(). Since this lock is used to serialize power supply property access, it appears we should be using hwmon_lock() instead.

Quoted 2 lines
drivers/hwmon/applesmc.c +2 -0
+
+static int applesmc_bat_get_property(struct power_supply *psy,

[ ... ]

Quoted 11 lines
drivers/hwmon/applesmc.c +11 -0
+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:

drivers/hwmon/applesmc.c static struct platform_driver applesmc_driver = { · line 795

Quoted 10 lines
drivers/hwmon/applesmc.c +10 -0
+		/* 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) {

[Severity: Medium]
As mentioned above, should this be using hwmon_lock() to serialize access instead of the custom applesmc_bat_lock?

Quoted 1 line
drivers/hwmon/applesmc.c +1 -0
+			ret = applesmc_write_key(BATTERY_CHARGE_LIMIT_KEY, &limit, 1);

[ ... ]

drivers/hwmon/applesmc.c static struct platform_driver applesmc_driver = { · line 851

Quoted 13 lines
drivers/hwmon/applesmc.c +13 -0
+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);
+}

[Severity: Medium]
Is this direct registration of the power supply extension bypassing the hwmon subsystem layering rules?

The hardware monitoring subsystem guidelines state that secondary functionality (like power supply properties) should be implemented as an auxiliary device driver, with the driver residing in the appropriate subsystem directory, rather than being registered directly from the hwmon driver.

drivers/hwmon/applesmc.c static struct platform_driver applesmc_driver = { · line 863

Quoted 12 lines
drivers/hwmon/applesmc.c +12 -0
+
+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,
+};

[Severity: Medium]
Similar to the power supply extension above, should this ACPI battery hook also be separated into an auxiliary device driver?

Registering it directly here in the hardware monitoring driver tightly couples unrelated subsystems and bypasses proper review from the power supply maintainers.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3