summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-04-17 21:24:00 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2026-04-17 21:24:00 +0300
commitd97e7d7c304f87419921f740743f7baa99f40539 (patch)
treeaf6b5ff258e9854490e205fb4ea348e08c6c125f /include
parent87768582a440e7049a04e8af7383b86738d15b38 (diff)
parentb8a5774cd49996e8ef83b1637a9b547158f18de9 (diff)
downloadlinux-d97e7d7c304f87419921f740743f7baa99f40539.tar.xz
Merge tag 'hid-for-linus-2026041601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID updates from Jiri Kosina: "Core: - fixed handling of 0-sized reports (Dmitry Torokhov) - convert core code to __free() (Dmitry Torokhov) - support for multiple batteries per HID device (Lucas Zampieri) Drivers: - support for rumble effects in winwing driver (Ivan Gorinov) - new support for a variety of Sony Rock Band and Sony DJ Hero Turntable devices (Rosalie Wanders) - new driver for Lenovo Legion Go / S devices (Derek J. Clark) - power management improvements to intel-thc-hid driver (Even Xu) ... other assorted cleanups, fixes and device-specific quirks" * tag 'hid-for-linus-2026041601' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (73 commits) HID: core: clamp report_size in s32ton() to avoid undefined shift HID: logitech-dj: fix wrong detection of bad DJ_SHORT output report HID: logitech-hidpp: fix race condition when accessing stale stack pointer HID: winwing: Enable rumble effects HID: core: do not allow parsing 0-sized reports HID: usbhid: refactor endpoint lookup HID: huawei: fix CD30 keyboard report descriptor issue HID: playstation: validate num_touch_reports in DualShock 4 reports HID: drop 'default !EXPERT' from tristate symbols HID: usbhid: fix deadlock in hid_post_reset() HID: apple: ensure the keyboard backlight is off if suspending HID: quirks: Set ALWAYS_POLL for LOGITECH_BOLT_RECEIVER HID: alps: fix NULL pointer dereference in alps_raw_event() HID: logitech-dj: Prevent REPORT_ID_DJ_SHORT related user initiated OOB write HID: logitech-dj: Standardise hid_report_enum variable nomenclature HID: sony: update module description HID: logitech-hidpp: Check bounds when deleting force-feedback effects HID: sony: add battery status support for Rock Band 4 PS5 guitars HID: sony: fix style issues HID: quirks: update hid-sony supported devices ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/device.h46
-rw-r--r--include/linux/hid.h58
2 files changed, 91 insertions, 13 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index f0d52e1a6e07..67cec9ec0cd0 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -190,6 +190,22 @@ ssize_t device_show_string(struct device *dev, struct device_attribute *attr,
struct device_attribute dev_attr_##_name = __ATTR_RW_MODE(_name, 0600)
/**
+ * DEVICE_ATTR_RW_NAMED - Define a read-write device attribute with a sysfs name
+ * that differs from the function name.
+ * @_name: Attribute function preface
+ * @_attrname: Attribute name as it wil be exposed in the sysfs.
+ *
+ * Like DEVICE_ATTR_RW(), but allows for reusing names under separate paths in
+ * the same driver.
+ */
+#define DEVICE_ATTR_RW_NAMED(_name, _attrname) \
+ struct device_attribute dev_attr_##_name = { \
+ .attr = { .name = _attrname, .mode = 0644 }, \
+ .show = _name##_show, \
+ .store = _name##_store, \
+ }
+
+/**
* DEVICE_ATTR_RO - Define a readable device attribute.
* @_name: Attribute name.
*
@@ -208,6 +224,21 @@ ssize_t device_show_string(struct device *dev, struct device_attribute *attr,
struct device_attribute dev_attr_##_name = __ATTR_RO_MODE(_name, 0400)
/**
+ * DEVICE_ATTR_RO_NAMED - Define a read-only device attribute with a sysfs name
+ * that differs from the function name.
+ * @_name: Attribute function preface
+ * @_attrname: Attribute name as it wil be exposed in the sysfs.
+ *
+ * Like DEVICE_ATTR_RO(), but allows for reusing names under separate paths in
+ * the same driver.
+ */
+#define DEVICE_ATTR_RO_NAMED(_name, _attrname) \
+ struct device_attribute dev_attr_##_name = { \
+ .attr = { .name = _attrname, .mode = 0444 }, \
+ .show = _name##_show, \
+ }
+
+/**
* DEVICE_ATTR_WO - Define an admin-only writable device attribute.
* @_name: Attribute name.
*
@@ -217,6 +248,21 @@ ssize_t device_show_string(struct device *dev, struct device_attribute *attr,
struct device_attribute dev_attr_##_name = __ATTR_WO(_name)
/**
+ * DEVICE_ATTR_WO_NAMED - Define a read-only device attribute with a sysfs name
+ * that differs from the function name.
+ * @_name: Attribute function preface
+ * @_attrname: Attribute name as it wil be exposed in the sysfs.
+ *
+ * Like DEVICE_ATTR_WO(), but allows for reusing names under separate paths in
+ * the same driver.
+ */
+#define DEVICE_ATTR_WO_NAMED(_name, _attrname) \
+ struct device_attribute dev_attr_##_name = { \
+ .attr = { .name = _attrname, .mode = 0200 }, \
+ .store = _name##_store, \
+ }
+
+/**
* DEVICE_ULONG_ATTR - Define a device attribute backed by an unsigned long.
* @_name: Attribute name.
* @_mode: File mode.
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 31324609af4d..442a80d79e89 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -634,6 +634,38 @@ enum hid_battery_status {
HID_BATTERY_REPORTED, /* Device sent unsolicited battery strength report */
};
+/**
+ * struct hid_battery - represents a single battery power supply
+ * @dev: pointer to the parent hid_device
+ * @ps: the power supply instance
+ * @min: minimum battery value from HID descriptor
+ * @max: maximum battery value from HID descriptor
+ * @report_type: HID report type (input/feature)
+ * @report_id: HID report ID for this battery
+ * @charge_status: current charging status
+ * @status: battery reporting status
+ * @capacity: current battery capacity (0-100)
+ * @avoid_query: if true, avoid querying battery (e.g., for stylus)
+ * @present: if true, battery is present (may be dynamic)
+ * @ratelimit_time: rate limiting for battery reports
+ * @list: list node for linking into hid_device's battery list
+ */
+struct hid_battery {
+ struct hid_device *dev;
+ struct power_supply *ps;
+ __s32 min;
+ __s32 max;
+ __s32 report_type;
+ __s32 report_id;
+ __s32 charge_status;
+ enum hid_battery_status status;
+ __s32 capacity;
+ bool avoid_query;
+ bool present;
+ ktime_t ratelimit_time;
+ struct list_head list;
+};
+
struct hid_driver;
struct hid_ll_driver;
@@ -670,20 +702,10 @@ struct hid_device {
#ifdef CONFIG_HID_BATTERY_STRENGTH
/*
* Power supply information for HID devices which report
- * battery strength. power_supply was successfully registered if
- * battery is non-NULL.
+ * battery strength. Each battery is tracked separately in the
+ * batteries list.
*/
- struct power_supply *battery;
- __s32 battery_capacity;
- __s32 battery_min;
- __s32 battery_max;
- __s32 battery_report_type;
- __s32 battery_report_id;
- __s32 battery_charge_status;
- enum hid_battery_status battery_status;
- bool battery_avoid_query;
- bool battery_present;
- ktime_t battery_ratelimit_time;
+ struct list_head batteries;
#endif
unsigned long status; /* see STAT flags above */
@@ -699,6 +721,7 @@ struct hid_device {
char name[128]; /* Device name */
char phys[64]; /* Device physical location */
char uniq[64]; /* Device unique identifier (serial #) */
+ u64 firmware_version; /* Firmware version */
void *driver_data;
@@ -744,6 +767,15 @@ static inline void hid_set_drvdata(struct hid_device *hdev, void *data)
dev_set_drvdata(&hdev->dev, data);
}
+#ifdef CONFIG_HID_BATTERY_STRENGTH
+static inline struct hid_battery *hid_get_battery(struct hid_device *hdev)
+{
+ if (list_empty(&hdev->batteries))
+ return NULL;
+ return list_first_entry(&hdev->batteries, struct hid_battery, list);
+}
+#endif
+
#define HID_GLOBAL_STACK_SIZE 4
#define HID_COLLECTION_STACK_SIZE 4