mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-12 01:25:43 -04:00
Some battery drivers need to consume monitored-battery data before their power_supply is visible. That lets them prepare hardware configuration from parsed battery information without racing userspace exposure. power_supply_get_battery_info() already runs in __power_supply_register() for battery devices before device_add(). Add an optional descriptor init callback after driver data and battery info are available. The callback runs in sleepable process context while the power supply is still unpublished. Keep the callback synchronous: it must not publish changes or start asynchronous activity that can access the power supply before registration completes. Require callbacks to return zero or a negative errno. Defensively reject positive returns so registration cannot return an invalid error pointer. Assisted-by: OpenCode:gpt-5.6-sol Signed-off-by: Vincent Cloutier <vincent@cloutier.co> Link: https://patch.msgid.link/20260727011319.621794-2-vincent.cloutier@icloud.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>