[RFC PATCH v2 1/3] HID: input: Introduce struct hid_battery
From: Lucas Zampieri
Date: Wed Nov 12 2025 - 19:15:18 EST
Add struct hid_battery to encapsulate battery state per HID device.
This structure will allow tracking individual battery properties
including capacity, min/max values, report information, and status.
The structure includes a list node to enable support for multiple
batteries per device in subsequent patches.
This is a preparation step for transitioning from direct power_supply
access to a more flexible battery management system.
Signed-off-by: Lucas Zampieri <lzampier@xxxxxxxxxx>
---
include/linux/hid.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/include/linux/hid.h b/include/linux/hid.h
index a4ddb94e3ee5..63422130de20 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -634,6 +634,36 @@ enum hid_battery_status {
HID_BATTERY_REPORTED, /* Device sent unsolicited battery strength report */
};
+/**
+ * struct hid_battery - represents a single battery power supply
+ * @list: list node for linking into hid_device's battery list
+ * @dev: pointer to the parent hid_device
+ * @ps: the power supply device
+ * @capacity: current battery capacity
+ * @min: minimum battery value
+ * @max: maximum battery value
+ * @report_type: type of report (HID_INPUT_REPORT, HID_FEATURE_REPORT)
+ * @report_id: report ID for this battery
+ * @charge_status: current charge status
+ * @status: battery status (unknown, queried, reported)
+ * @avoid_query: if true, don't query battery (wait for device reports)
+ * @ratelimit_time: time for rate limiting battery updates
+ */
+struct hid_battery {
+ struct list_head list;
+ struct hid_device *dev;
+ struct power_supply *ps;
+ __s32 capacity;
+ __s32 min;
+ __s32 max;
+ __s32 report_type;
+ __s32 report_id;
+ __s32 charge_status;
+ enum hid_battery_status status;
+ bool avoid_query;
+ ktime_t ratelimit_time;
+};
+
struct hid_driver;
struct hid_ll_driver;
--
2.51.1