]> git.ipfire.org Git - thirdparty/linux.git/commit
HID: input: Introduce struct hid_battery and refactor battery code
authorLucas Zampieri <lcasmz54@gmail.com>
Sat, 14 Mar 2026 01:05:29 +0000 (01:05 +0000)
committerBenjamin Tissoires <bentiss@kernel.org>
Thu, 19 Mar 2026 14:52:45 +0000 (15:52 +0100)
commit7a3ac62473f2bd213557e41aaab7a8f144037dfd
tree13bd25b00b278cbd29457d9614b13c860bccc4e6
parent5a9df498581a2e12fd960ddeb1da41dd771d9000
HID: input: Introduce struct hid_battery and refactor battery code

Introduce struct hid_battery to encapsulate individual battery state,
preparing for future multi-battery support.

The new structure contains all battery-related fields previously stored
directly in hid_device (capacity, min, max, report_type, report_id,
charge_status, etc.). The hid_device->battery pointer type changes from
struct power_supply* to struct hid_battery*, and all battery functions
are refactored accordingly.

A hid_get_battery() helper is added for external drivers, with
hid-apple.c and hid-magicmouse.c updated to use the new API. The
hid-input-test.c KUnit tests are also updated for the new structure.

No functional changes for single-battery devices.

Signed-off-by: Lucas Zampieri <lcasmz54@gmail.com>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/hid-apple.c
drivers/hid/hid-input-test.c
drivers/hid/hid-input.c
drivers/hid/hid-magicmouse.c
include/linux/hid.h