Skip to contentSkip to conversation

HID: hp: Add support for HyperX headset devices

PATCH Superseded Sofia Schneider 2 participants 4 messages Aug 4 – Aug 16 HID

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 HID: hp: Add support for HyperX headset devices

Introduce a HID driver for HyperX Cloud III Wireless headsets, supporting battery reporting and connection status.

Tested with a HyperX Cloud III Wireless only, for lack of other testable devices.

---
v3 -> v4:
- Rename driver to hid-hp.

v2 -> v3:
- Unregister power supply on hid_hw_start() failure in probe() to prevent UAF/resource leak.

v1 -> v2:
- Call hid_hw_stop() before cancelling work queues in remove() to prevent UAF.
- Safe unregistration of power supply using the spinlock in remove() to prevent race conditions.
- Cancel battery_work in the hid_hw_start() error path in probe() to prevent UAF.
- Dynamically allocate power supply names to avoid sysfs naming collisions.

v1: https://lore.kernel.org/linux-input/[email protected]/T/
v2: https://lore.kernel.org/linux-input/[email protected]/T/
v3: https://lore.kernel.org/linux-input/[email protected]/T/

 MAINTAINERS           |   6 +
 drivers/hid/Kconfig   |  11 ++
 drivers/hid/Makefile  |   1 +
 drivers/hid/hid-hp.c  | 399 ++++++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h |   1 +
 5 files changed, 418 insertions(+)
 create mode 100644 drivers/hid/hid-hp.c
MAINTAINERS +6 -0
index d8252026bbd4..6d3bb16673fd 100644
@@ -11419,6 +11419,12 @@ F:	include/uapi/linux/hid*
 F:	samples/hid/
 F:	tools/testing/selftests/hid/
 
+HID HP DRIVER
+M:	Sofia Schneider <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/hid/hid-hp.c
+
 HID LOGITECH DRIVERS
 R:	Filipe Laíns <[email protected]>
 L:	[email protected]
drivers/hid/Kconfig +11 -0
index f9bcaeb66385..42e4aa00bdc0 100644
@@ -1215,6 +1215,17 @@ config HID_HYPERV_MOUSE
 	help
 	Select this option to enable the Hyper-V mouse driver.
 
+config HID_HP
+	tristate "HP HID devices"
+	depends on USB_HID
+	select POWER_SUPPLY
+	help
+	Support for HP HID devices, including HyperX headsets.
+
+	Say Y here if you would like to enable support for HP HID devices.
+	To compile this driver as a module, choose M here: the module will be called
+	hid-hp.
+
 config HID_SMARTJOYPLUS
 	tristate "SmartJoy PLUS PS2/USB adapter support"
 	help
drivers/hid/Makefile +1 -0
index 23e6e3dd0c56..c6cdf6048ddd 100644
@@ -67,6 +67,7 @@ obj-$(CONFIG_HID_HOLTEK)	+= hid-holtek-kbd.o
 obj-$(CONFIG_HID_HOLTEK)	+= hid-holtek-mouse.o
 obj-$(CONFIG_HID_HOLTEK)	+= hid-holtekff.o
 obj-$(CONFIG_HID_HYPERV_MOUSE)	+= hid-hyperv.o
+obj-$(CONFIG_HID_HP)			+= hid-hp.o
 obj-$(CONFIG_HID_ICADE)		+= hid-icade.o
 obj-$(CONFIG_HID_ITE)		+= hid-ite.o
 obj-$(CONFIG_HID_JABRA)		+= hid-jabra.o
drivers/hid/hid-hp.c new file +399 -0

399 lines not on this page · raw message

drivers/hid/hid-ids.h +1 -0
index 1059922baaac..aa2c3a71315b 100644
@@ -696,6 +696,7 @@
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_0941	0x0941
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_0641	0x0641
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_1f4a	0x1f4a
+#define USB_DEVICE_ID_HP_HYPERX_CLOUD_III_WIRELESS 0x05b7
 
 #define USB_VENDOR_ID_HUION		0x256c
 #define USB_DEVICE_ID_HUION_TABLET	0x006e
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/1 Add support for HyperX cloud 2 wireless.

Add the device ID for HyperX cloud 2 wireless, which requires the same handling as the devices support by this driver.

Tested with HyperX cloud 2 wireless.

(
I was about to submit a patch for my own driver for HyperX devices
(https://github.com/IdanKoblik/hid-hyperx), but I noticed that you had already submitted support for the HyperX Cloud III Wireless last week :( Anyway, here's a small patch to add support for the HyperX Cloud II Wireless to the existing driver.
)

---
 drivers/hid/hid-hp.c  | 2 ++
 drivers/hid/hid-ids.h | 1 +
 2 files changed, 3 insertions(+)
drivers/hid/hid-hp.c +2 -0
index fa53d5f6c..84ea358ea 100644
@@ -381,6 +381,8 @@ static void hp_remove(struct hid_device *hdev)
 static const struct hid_device_id hp_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_HP,
 			 USB_DEVICE_ID_HP_HYPERX_CLOUD_III_WIRELESS) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_HP,
+			 USB_DEVICE_ID_HP_HYPERX_CLOUD_II_WIRELESS) },
 	{}
 };
 MODULE_DEVICE_TABLE(hid, hp_devices);
drivers/hid/hid-ids.h +1 -0
index aa2c3a713..a8a37a936 100644
@@ -697,6 +697,7 @@
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_0641	0x0641
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_1f4a	0x1f4a
 #define USB_DEVICE_ID_HP_HYPERX_CLOUD_III_WIRELESS 0x05b7
+#define USB_DEVICE_ID_HP_HYPERX_CLOUD_II_WIRELESS 0x0995
 
 #define USB_VENDOR_ID_HUION		0x256c
 #define USB_DEVICE_ID_HUION_TABLET	0x006e

base-commit: 3d6d817622b0a9721e3cc404df3469171582be13
prerequisite-patch-id: 8d99df67dab75c0c6cbc887b2ea6be90be288037

Signature · 1 line
2.55.0
author Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] Add support for HyperX cloud 2 wireless.

Quoted 6 lines · Idan Koblik

Add the device ID for HyperX cloud 2 wireless, which requires the same handling as the devices support by this driver.

Tested with HyperX cloud 2 wireless.

Hi Idan,

Thanks for the patch! The code looks good, but the commit subject and message need a little editing to match kernel standards:

1. Please add "HID: hp: " as a prefix to the subject and remove the trailing period:
HID: hp: Add support for HyperX Cloud II Wireless

2. The note in parentheses (about your GitHub repo) should be moved below the "---" line so it doesn't appear in the permanent git log, or removed.

With those fixed in v2:

Note for Jiri/Benjamin: This patch applies on top of my pending v4 driver patch ([PATCH v4] HID: hp: Add support for HyperX headset devices)

#3 lore raw

PATCH v2 1/1 HID: hp: Add support for HyperX Cloud II Wireless

In reply to Idan Koblik

Add the device ID for HyperX cloud 2 wireless, which requires the same handling as the devices support by this driver.

Tested with HyperX cloud 2 wireless.

---
 drivers/hid/hid-hp.c  | 2 ++
 drivers/hid/hid-ids.h | 1 +
 2 files changed, 3 insertions(+)
drivers/hid/hid-hp.c +2 -0
index fa53d5f6c..84ea358ea 100644
@@ -381,6 +381,8 @@ static void hp_remove(struct hid_device *hdev)
 static const struct hid_device_id hp_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_HP,
 			 USB_DEVICE_ID_HP_HYPERX_CLOUD_III_WIRELESS) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_HP,
+			 USB_DEVICE_ID_HP_HYPERX_CLOUD_II_WIRELESS) },
 	{}
 };
 MODULE_DEVICE_TABLE(hid, hp_devices);
drivers/hid/hid-ids.h +1 -0
index aa2c3a713..a8a37a936 100644
@@ -697,6 +697,7 @@
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_0641	0x0641
 #define USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE_1f4a	0x1f4a
 #define USB_DEVICE_ID_HP_HYPERX_CLOUD_III_WIRELESS 0x05b7
+#define USB_DEVICE_ID_HP_HYPERX_CLOUD_II_WIRELESS 0x0995
 
 #define USB_VENDOR_ID_HUION		0x256c
 #define USB_DEVICE_ID_HUION_TABLET	0x006e
Signature · 1 line
2.55.0