Re: [PATCH 1/2] ACPI: sbs: add battery hook mechanism for SBS-registered batteries
From: Thomas Weißschuh
Date: Wed Sep 16 2026 - 13:30:40 EST
On 2026-09-13 17:14:09-0600, Jordan Brough wrote:
(...)
> Add a parallel sbs_battery_hook_register()/unregister() mechanism to
> drivers/acpi/sbs.c, mirroring the existing CmBatt hook API in name and
> behavior so that callers can support both battery registration paths
> symmetrically. This is purely additive: no existing hook consumer or
> code path in drivers/acpi/battery.c is touched, and sbs.c's own
> behavior is unchanged for any driver that does not call the new API.
(...)
> ---
> drivers/acpi/sbs.c | 147 ++++++++++++++++++++++++++++++++++++++++-
> include/acpi/battery.h | 16 +++++
> 2 files changed, 162 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index 86b7c797585..305bf62eae3 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
(...)
> +/*
> + * Battery hook support, mirroring the mechanism in drivers/acpi/battery.c
> + * for batteries registered there. That mechanism only sees batteries
> + * added via drivers/acpi/battery.c, not the ones this driver registers,
> + * so drivers wanting to attach optional functionality (e.g. an extra
> + * power_supply_ext) to an SBS battery need this separate copy; see the
> + * comment above the declarations in include/acpi/battery.h.
> + */
(...)
This completely duplicates the hooking logic in battery.c.
Also it forces drivers to register both kinds of hooks explicitly.
Couldn't we have a single shared hooking infrastructure and registry
which avoid both issues?
(...)
Thomas