Skip to content

Commit 1f34279

Browse files
committed
Merge tag 'for-linus-2023112301' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - revert of commit that caused regression to many Logitech unifying receiver users (Jiri Kosina) - power management fix for hid-mcp2221 (Hamish Martin) - fix for race condition between HID core and HID debug (Charles Yi) - a couple of assorted device-ID-specific quirks * tag 'for-linus-2023112301' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: multitouch: Add quirk for HONOR GLO-GXXX touchpad HID: hid-asus: reset the backlight brightness level on resume HID: hid-asus: add const to read-only outgoing usb buffer Revert "HID: logitech-dj: Add support for a new lightspeed receiver iteration" HID: add ALWAYS_POLL quirk for Apple kb HID: glorious: fix Glorious Model I HID report HID: fix HID device resource race between HID core and debugging support HID: apple: add Jamesdonkey and A3R to non-apple keyboards list HID: mcp2221: Allow IO to start during probe HID: mcp2221: Set driver data before I2C adapter add
2 parents d3fa86b + 9ffccb6 commit 1f34279

File tree

11 files changed

+74
-22
lines changed

11 files changed

+74
-22
lines changed

drivers/hid/hid-apple.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ static const struct apple_non_apple_keyboard non_apple_keyboards[] = {
345345
{ "AONE" },
346346
{ "GANSS" },
347347
{ "Hailuck" },
348+
{ "Jamesdonkey" },
349+
{ "A3R" },
348350
};
349351

350352
static bool apple_is_non_apple_keyboard(struct hid_device *hdev)

drivers/hid/hid-asus.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static int asus_raw_event(struct hid_device *hdev,
381381
return 0;
382382
}
383383

384-
static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size)
384+
static int asus_kbd_set_report(struct hid_device *hdev, const u8 *buf, size_t buf_size)
385385
{
386386
unsigned char *dmabuf;
387387
int ret;
@@ -404,7 +404,7 @@ static int asus_kbd_set_report(struct hid_device *hdev, u8 *buf, size_t buf_size
404404

405405
static int asus_kbd_init(struct hid_device *hdev)
406406
{
407-
u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
407+
const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x41, 0x53, 0x55, 0x53, 0x20, 0x54,
408408
0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
409409
int ret;
410410

@@ -418,7 +418,7 @@ static int asus_kbd_init(struct hid_device *hdev)
418418
static int asus_kbd_get_functions(struct hid_device *hdev,
419419
unsigned char *kbd_func)
420420
{
421-
u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
421+
const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0x05, 0x20, 0x31, 0x00, 0x08 };
422422
u8 *readbuf;
423423
int ret;
424424

@@ -449,7 +449,7 @@ static int asus_kbd_get_functions(struct hid_device *hdev,
449449

450450
static int rog_nkey_led_init(struct hid_device *hdev)
451451
{
452-
u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
452+
const u8 buf_init_start[] = { FEATURE_KBD_LED_REPORT_ID1, 0xB9 };
453453
u8 buf_init2[] = { FEATURE_KBD_LED_REPORT_ID1, 0x41, 0x53, 0x55, 0x53, 0x20,
454454
0x54, 0x65, 0x63, 0x68, 0x2e, 0x49, 0x6e, 0x63, 0x2e, 0x00 };
455455
u8 buf_init3[] = { FEATURE_KBD_LED_REPORT_ID1,
@@ -1000,6 +1000,24 @@ static int asus_start_multitouch(struct hid_device *hdev)
10001000
return 0;
10011001
}
10021002

1003+
static int __maybe_unused asus_resume(struct hid_device *hdev) {
1004+
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
1005+
int ret = 0;
1006+
1007+
if (drvdata->kbd_backlight) {
1008+
const u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4,
1009+
drvdata->kbd_backlight->cdev.brightness };
1010+
ret = asus_kbd_set_report(hdev, buf, sizeof(buf));
1011+
if (ret < 0) {
1012+
hid_err(hdev, "Asus failed to set keyboard backlight: %d\n", ret);
1013+
goto asus_resume_err;
1014+
}
1015+
}
1016+
1017+
asus_resume_err:
1018+
return ret;
1019+
}
1020+
10031021
static int __maybe_unused asus_reset_resume(struct hid_device *hdev)
10041022
{
10051023
struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
@@ -1294,6 +1312,7 @@ static struct hid_driver asus_driver = {
12941312
.input_configured = asus_input_configured,
12951313
#ifdef CONFIG_PM
12961314
.reset_resume = asus_reset_resume,
1315+
.resume = asus_resume,
12971316
#endif
12981317
.event = asus_event,
12991318
.raw_event = asus_raw_event

drivers/hid/hid-core.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,22 @@ static void hid_close_report(struct hid_device *device)
702702
* Free a device structure, all reports, and all fields.
703703
*/
704704

705-
static void hid_device_release(struct device *dev)
705+
void hiddev_free(struct kref *ref)
706706
{
707-
struct hid_device *hid = to_hid_device(dev);
707+
struct hid_device *hid = container_of(ref, struct hid_device, ref);
708708

709709
hid_close_report(hid);
710710
kfree(hid->dev_rdesc);
711711
kfree(hid);
712712
}
713713

714+
static void hid_device_release(struct device *dev)
715+
{
716+
struct hid_device *hid = to_hid_device(dev);
717+
718+
kref_put(&hid->ref, hiddev_free);
719+
}
720+
714721
/*
715722
* Fetch a report description item from the data stream. We support long
716723
* items, though they are not used yet.
@@ -2846,6 +2853,7 @@ struct hid_device *hid_allocate_device(void)
28462853
spin_lock_init(&hdev->debug_list_lock);
28472854
sema_init(&hdev->driver_input_lock, 1);
28482855
mutex_init(&hdev->ll_open_lock);
2856+
kref_init(&hdev->ref);
28492857

28502858
hid_bpf_device_init(hdev);
28512859

drivers/hid/hid-debug.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
11351135
goto out;
11361136
}
11371137
list->hdev = (struct hid_device *) inode->i_private;
1138+
kref_get(&list->hdev->ref);
11381139
file->private_data = list;
11391140
mutex_init(&list->read_mutex);
11401141

@@ -1227,6 +1228,8 @@ static int hid_debug_events_release(struct inode *inode, struct file *file)
12271228
list_del(&list->node);
12281229
spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
12291230
kfifo_free(&list->hid_debug_fifo);
1231+
1232+
kref_put(&list->hdev->ref, hiddev_free);
12301233
kfree(list);
12311234

12321235
return 0;

drivers/hid/hid-glorious.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ MODULE_DESCRIPTION("HID driver for Glorious PC Gaming Race mice");
2121
* Glorious Model O and O- specify the const flag in the consumer input
2222
* report descriptor, which leads to inputs being ignored. Fix this
2323
* by patching the descriptor.
24+
*
25+
* Glorious Model I incorrectly specifes the Usage Minimum for its
26+
* keyboard HID report, causing keycodes to be misinterpreted.
27+
* Fix this by setting Usage Minimum to 0 in that report.
2428
*/
2529
static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2630
unsigned int *rsize)
@@ -32,6 +36,10 @@ static __u8 *glorious_report_fixup(struct hid_device *hdev, __u8 *rdesc,
3236
rdesc[85] = rdesc[113] = rdesc[141] = \
3337
HID_MAIN_ITEM_VARIABLE | HID_MAIN_ITEM_RELATIVE;
3438
}
39+
if (*rsize == 156 && rdesc[41] == 1) {
40+
hid_info(hdev, "patching Glorious Model I keyboard report descriptor\n");
41+
rdesc[41] = 0;
42+
}
3543
return rdesc;
3644
}
3745

@@ -44,6 +52,8 @@ static void glorious_update_name(struct hid_device *hdev)
4452
model = "Model O"; break;
4553
case USB_DEVICE_ID_GLORIOUS_MODEL_D:
4654
model = "Model D"; break;
55+
case USB_DEVICE_ID_GLORIOUS_MODEL_I:
56+
model = "Model I"; break;
4757
}
4858

4959
snprintf(hdev->name, sizeof(hdev->name), "%s %s", "Glorious", model);
@@ -66,10 +76,12 @@ static int glorious_probe(struct hid_device *hdev,
6676
}
6777

6878
static const struct hid_device_id glorious_devices[] = {
69-
{ HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
79+
{ HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7080
USB_DEVICE_ID_GLORIOUS_MODEL_O) },
71-
{ HID_USB_DEVICE(USB_VENDOR_ID_GLORIOUS,
81+
{ HID_USB_DEVICE(USB_VENDOR_ID_SINOWEALTH,
7282
USB_DEVICE_ID_GLORIOUS_MODEL_D) },
83+
{ HID_USB_DEVICE(USB_VENDOR_ID_LAVIEW,
84+
USB_DEVICE_ID_GLORIOUS_MODEL_I) },
7385
{ }
7486
};
7587
MODULE_DEVICE_TABLE(hid, glorious_devices);

drivers/hid/hid-ids.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,6 @@
511511
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
512512
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100
513513

514-
#define USB_VENDOR_ID_GLORIOUS 0x258a
515-
#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
516-
#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
517-
518514
#define I2C_VENDOR_ID_GOODIX 0x27c6
519515
#define I2C_DEVICE_ID_GOODIX_01F0 0x01f0
520516

@@ -745,6 +741,9 @@
745741
#define USB_VENDOR_ID_LABTEC 0x1020
746742
#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006
747743

744+
#define USB_VENDOR_ID_LAVIEW 0x22D4
745+
#define USB_DEVICE_ID_GLORIOUS_MODEL_I 0x1503
746+
748747
#define USB_VENDOR_ID_LCPOWER 0x1241
749748
#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767
750749

@@ -869,7 +868,6 @@
869868
#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_2 0xc534
870869
#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1 0xc539
871870
#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1 0xc53f
872-
#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2 0xc547
873871
#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY 0xc53a
874872
#define USB_DEVICE_ID_SPACETRAVELLER 0xc623
875873
#define USB_DEVICE_ID_SPACENAVIGATOR 0xc626
@@ -1160,6 +1158,10 @@
11601158
#define USB_VENDOR_ID_SIGMATEL 0x066F
11611159
#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
11621160

1161+
#define USB_VENDOR_ID_SINOWEALTH 0x258a
1162+
#define USB_DEVICE_ID_GLORIOUS_MODEL_D 0x0033
1163+
#define USB_DEVICE_ID_GLORIOUS_MODEL_O 0x0036
1164+
11631165
#define USB_VENDOR_ID_SIS_TOUCH 0x0457
11641166
#define USB_DEVICE_ID_SIS9200_TOUCH 0x9200
11651167
#define USB_DEVICE_ID_SIS817_TOUCH 0x0817

drivers/hid/hid-logitech-dj.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,12 +1695,11 @@ static int logi_dj_raw_event(struct hid_device *hdev,
16951695
}
16961696
/*
16971697
* Mouse-only receivers send unnumbered mouse data. The 27 MHz
1698-
* receiver uses 6 byte packets, the nano receiver 8 bytes,
1699-
* the lightspeed receiver (Pro X Superlight) 13 bytes.
1698+
* receiver uses 6 byte packets, the nano receiver 8 bytes.
17001699
*/
17011700
if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
1702-
size <= 13){
1703-
u8 mouse_report[14];
1701+
size <= 8) {
1702+
u8 mouse_report[9];
17041703

17051704
/* Prepend report id */
17061705
mouse_report[0] = REPORT_TYPE_MOUSE;
@@ -1984,10 +1983,6 @@ static const struct hid_device_id logi_dj_receivers[] = {
19841983
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
19851984
USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1),
19861985
.driver_data = recvr_type_gaming_hidpp},
1987-
{ /* Logitech lightspeed receiver (0xc547) */
1988-
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1989-
USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2),
1990-
.driver_data = recvr_type_gaming_hidpp},
19911986

19921987
{ /* Logitech 27 MHz HID++ 1.0 receiver (0xc513) */
19931988
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),

drivers/hid/hid-mcp2221.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,8 @@ static int mcp2221_probe(struct hid_device *hdev,
11421142
if (ret)
11431143
return ret;
11441144

1145+
hid_device_io_start(hdev);
1146+
11451147
/* Set I2C bus clock diviser */
11461148
if (i2c_clk_freq > 400)
11471149
i2c_clk_freq = 400;
@@ -1157,12 +1159,12 @@ static int mcp2221_probe(struct hid_device *hdev,
11571159
snprintf(mcp->adapter.name, sizeof(mcp->adapter.name),
11581160
"MCP2221 usb-i2c bridge");
11591161

1162+
i2c_set_adapdata(&mcp->adapter, mcp);
11601163
ret = devm_i2c_add_adapter(&hdev->dev, &mcp->adapter);
11611164
if (ret) {
11621165
hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
11631166
return ret;
11641167
}
1165-
i2c_set_adapdata(&mcp->adapter, mcp);
11661168

11671169
#if IS_REACHABLE(CONFIG_GPIOLIB)
11681170
/* Setup GPIO chip */

drivers/hid/hid-multitouch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,11 @@ static const struct hid_device_id mt_devices[] = {
20462046
MT_USB_DEVICE(USB_VENDOR_ID_HANVON_ALT,
20472047
USB_DEVICE_ID_HANVON_ALT_MULTITOUCH) },
20482048

2049+
/* HONOR GLO-GXXX panel */
2050+
{ .driver_data = MT_CLS_VTL,
2051+
HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
2052+
0x347d, 0x7853) },
2053+
20492054
/* Ilitek dual touch panel */
20502055
{ .driver_data = MT_CLS_NSMU,
20512056
MT_USB_DEVICE(USB_VENDOR_ID_ILITEK,

drivers/hid/hid-quirks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static const struct hid_device_id hid_quirks[] = {
3333
{ HID_USB_DEVICE(USB_VENDOR_ID_AKAI, USB_DEVICE_ID_AKAI_MPKMINI2), HID_QUIRK_NO_INIT_REPORTS },
3434
{ HID_USB_DEVICE(USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD), HID_QUIRK_BADPAD },
3535
{ HID_USB_DEVICE(USB_VENDOR_ID_AMI, USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE), HID_QUIRK_ALWAYS_POLL },
36+
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI), HID_QUIRK_ALWAYS_POLL },
3637
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM), HID_QUIRK_NOGET },
3738
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC), HID_QUIRK_NOGET },
3839
{ HID_USB_DEVICE(USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM), HID_QUIRK_NOGET },

0 commit comments

Comments
 (0)