From: Lucas Zampieri <lzampier@redhat.com>
To: linux-input@vger.kernel.org
Cc: Lucas Zampieri <lzampier@redhat.com>,
linux-kernel@vger.kernel.org, Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Sebastian Reichel <sre@kernel.org>,
Bastien Nocera <hadess@hadess.net>,
linux-pm@vger.kernel.org
Subject: [RFC PATCH v2 1/3] HID: input: Introduce struct hid_battery
Date: Thu, 13 Nov 2025 00:15:03 +0000 [thread overview]
Message-ID: <20251113001508.713574-2-lzampier@redhat.com> (raw)
In-Reply-To: <20251113001508.713574-1-lzampier@redhat.com>
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@redhat.com>
---
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
next prev parent reply other threads:[~2025-11-13 0:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 0:15 [RFC PATCH v2 0/3] HID: Add support for multiple batteries per device Lucas Zampieri
2025-11-13 0:15 ` Lucas Zampieri [this message]
2025-11-13 10:47 ` [RFC PATCH v2 1/3] HID: input: Introduce struct hid_battery Benjamin Tissoires
2025-11-13 11:56 ` Bastien Nocera
2025-11-13 0:15 ` [RFC PATCH v2 2/3] HID: input: Refactor battery code to use " Lucas Zampieri
2025-11-13 10:54 ` Benjamin Tissoires
2025-11-16 11:40 ` Lucas Zampieri
2025-11-13 0:15 ` [RFC PATCH v2 3/3] HID: input: Add support for multiple batteries per device Lucas Zampieri
2025-11-13 11:08 ` Benjamin Tissoires
2025-11-16 11:54 ` Lucas Zampieri
2025-11-13 10:44 ` [RFC PATCH v2 0/3] HID: " Benjamin Tissoires
2025-11-16 11:38 ` Lucas Zampieri
2025-11-13 11:16 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251113001508.713574-2-lzampier@redhat.com \
--to=lzampier@redhat.com \
--cc=bentiss@kernel.org \
--cc=hadess@hadess.net \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).