mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
ACPI: battery: add devm_battery_hook_register()
Add a utility function for device-managed registration of battery hooks. The function makes it easier to manage the lifecycle of a hook. Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240630-cros_ec-charge-control-v5-1-8f649d018c52@weissschuh.net Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
This commit is contained in:
parent
5b8feca8de
commit
2681bbaa39
@ -756,6 +756,21 @@ end:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(battery_hook_register);
|
||||
|
||||
static void devm_battery_hook_unregister(void *data)
|
||||
{
|
||||
struct acpi_battery_hook *hook = data;
|
||||
|
||||
battery_hook_unregister(hook);
|
||||
}
|
||||
|
||||
int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
|
||||
{
|
||||
battery_hook_register(hook);
|
||||
|
||||
return devm_add_action_or_reset(dev, devm_battery_hook_unregister, hook);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_battery_hook_register);
|
||||
|
||||
/*
|
||||
* This function gets called right after the battery sysfs
|
||||
* attributes have been added, so that the drivers that
|
||||
|
@ -2,6 +2,7 @@
|
||||
#ifndef __ACPI_BATTERY_H
|
||||
#define __ACPI_BATTERY_H
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
#define ACPI_BATTERY_CLASS "battery"
|
||||
@ -19,5 +20,6 @@ struct acpi_battery_hook {
|
||||
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user