Skip to content

Commit 2953fb6

Browse files
committed
Merge tag 'hid-for-linus-2025101701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - fix for sticky fingers handling in hid-multitouch (Benjamin Tissoires) - fix for reporting of 0 battery levels (Dmitry Torokhov) - build fix for hid-haptic in certain configurations (Jonathan Denose) - improved probe and avoiding spamming kernel log by hid-nintendo (Vicki Pfau) - fix for OOB in hid-cp2112 (Deepak Sharma) - interrupt handling fix for intel-thc-hid (Even Xu) - a couple of new device IDs and device-specific quirks * tag 'hid-for-linus-2025101701' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: logitech-hidpp: Add HIDPP_QUIRK_RESET_HI_RES_SCROLL selftests/hid: add tests for missing release on the Dell Synaptics HID: multitouch: fix sticky fingers HID: multitouch: fix name of Stylus input devices HID: hid-input: only ignore 0 battery events for digitizers HID: hid-debug: Fix spelling mistake "Rechargable" -> "Rechargeable" HID: Kconfig: Fix build error from CONFIG_HID_HAPTIC HID: nintendo: Rate limit IMU compensation message HID: nintendo: Wait longer for initial probe HID: core: Add printk_ratelimited variants to hid_warn() etc HID: quirks: Add ALWAYS_POLL quirk for VRS R295 steering wheel HID: quirks: avoid Cooler Master MM712 dongle wakeup bug HID: cp2112: Add parameter validation to data length HID: intel-thc-hid: intel-quickspi: Add ARL PCI Device Id's HID: intel-thc-hid: Intel-quickspi: switch first interrupt from level to edge detection HID: intel-thc-hid: intel-quicki2c: Fix wrong type casting
2 parents d303caf + ed80cc4 commit 2953fb6

File tree

15 files changed

+151
-25
lines changed

15 files changed

+151
-25
lines changed

drivers/hid/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ config HID_GENERIC
9393
If unsure, say Y.
9494

9595
config HID_HAPTIC
96-
tristate "Haptic touchpad support"
96+
bool "Haptic touchpad support"
9797
default n
9898
help
9999
Support for touchpads with force sensors and haptic actuators instead of a

drivers/hid/hid-cp2112.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,14 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
689689
count = cp2112_write_read_req(buf, addr, read_length,
690690
command, NULL, 0);
691691
} else {
692-
count = cp2112_write_req(buf, addr, command,
692+
/* Copy starts from data->block[1] so the length can
693+
* be at max I2C_SMBUS_CLOCK_MAX + 1
694+
*/
695+
696+
if (data->block[0] > I2C_SMBUS_BLOCK_MAX + 1)
697+
count = -EINVAL;
698+
else
699+
count = cp2112_write_req(buf, addr, command,
693700
data->block + 1,
694701
data->block[0]);
695702
}
@@ -700,7 +707,14 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
700707
I2C_SMBUS_BLOCK_MAX,
701708
command, NULL, 0);
702709
} else {
703-
count = cp2112_write_req(buf, addr, command,
710+
/* data_length here is data->block[0] + 1
711+
* so make sure that the data->block[0] is
712+
* less than or equals I2C_SMBUS_BLOCK_MAX + 1
713+
*/
714+
if (data->block[0] > I2C_SMBUS_BLOCK_MAX + 1)
715+
count = -EINVAL;
716+
else
717+
count = cp2112_write_req(buf, addr, command,
704718
data->block,
705719
data->block[0] + 1);
706720
}
@@ -709,7 +723,14 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
709723
size = I2C_SMBUS_BLOCK_DATA;
710724
read_write = I2C_SMBUS_READ;
711725

712-
count = cp2112_write_read_req(buf, addr, I2C_SMBUS_BLOCK_MAX,
726+
/* data_length is data->block[0] + 1, so
727+
* so data->block[0] should be less than or
728+
* equal to the I2C_SMBUS_BLOCK_MAX + 1
729+
*/
730+
if (data->block[0] > I2C_SMBUS_BLOCK_MAX + 1)
731+
count = -EINVAL;
732+
else
733+
count = cp2112_write_read_req(buf, addr, I2C_SMBUS_BLOCK_MAX,
713734
command, data->block,
714735
data->block[0] + 1);
715736
break;

drivers/hid/hid-debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
25232523
{ 0x85, 0x0088, "iDeviceName" },
25242524
{ 0x85, 0x0089, "iDeviceChemistry" },
25252525
{ 0x85, 0x008a, "ManufacturerData" },
2526-
{ 0x85, 0x008b, "Rechargable" },
2526+
{ 0x85, 0x008b, "Rechargeable" },
25272527
{ 0x85, 0x008c, "WarningCapacityLimit" },
25282528
{ 0x85, 0x008d, "CapacityGranularity1" },
25292529
{ 0x85, 0x008e, "CapacityGranularity2" },

drivers/hid/hid-ids.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@
342342
#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500
343343
#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff
344344

345+
#define USB_VENDOR_ID_COOLER_MASTER 0x2516
346+
#define USB_DEVICE_ID_COOLER_MASTER_MICE_DONGLE 0x01b7
347+
345348
#define USB_VENDOR_ID_CORSAIR 0x1b1c
346349
#define USB_DEVICE_ID_CORSAIR_K90 0x1b02
347350
#define USB_DEVICE_ID_CORSAIR_K70R 0x1b09
@@ -1432,6 +1435,7 @@
14321435

14331436
#define USB_VENDOR_ID_VRS 0x0483
14341437
#define USB_DEVICE_ID_VRS_DFP 0xa355
1438+
#define USB_DEVICE_ID_VRS_R295 0xa44c
14351439

14361440
#define USB_VENDOR_ID_VTL 0x0306
14371441
#define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f

drivers/hid/hid-input.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,10 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage,
635635
return;
636636
}
637637

638-
if (value == 0 || value < dev->battery_min || value > dev->battery_max)
638+
if ((usage & HID_USAGE_PAGE) == HID_UP_DIGITIZER && value == 0)
639+
return;
640+
641+
if (value < dev->battery_min || value > dev->battery_max)
639642
return;
640643

641644
capacity = hidinput_scale_battery_capacity(dev, value);

drivers/hid/hid-logitech-hidpp.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
7575
#define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS BIT(27)
7676
#define HIDPP_QUIRK_HI_RES_SCROLL_1P0 BIT(28)
7777
#define HIDPP_QUIRK_WIRELESS_STATUS BIT(29)
78+
#define HIDPP_QUIRK_RESET_HI_RES_SCROLL BIT(30)
7879

7980
/* These are just aliases for now */
8081
#define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS
@@ -193,6 +194,7 @@ struct hidpp_device {
193194
void *private_data;
194195

195196
struct work_struct work;
197+
struct work_struct reset_hi_res_work;
196198
struct kfifo delayed_work_fifo;
197199
struct input_dev *delayed_input;
198200

@@ -3836,6 +3838,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
38363838
struct hidpp_report *answer = hidpp->send_receive_buf;
38373839
struct hidpp_report *report = (struct hidpp_report *)data;
38383840
int ret;
3841+
int last_online;
38393842

38403843
/*
38413844
* If the mutex is locked then we have a pending answer from a
@@ -3877,6 +3880,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
38773880
"See: https://gitlab.freedesktop.org/jwrdegoede/logitech-27mhz-keyboard-encryption-setup/\n");
38783881
}
38793882

3883+
last_online = hidpp->battery.online;
38803884
if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) {
38813885
ret = hidpp20_battery_event_1000(hidpp, data, size);
38823886
if (ret != 0)
@@ -3901,6 +3905,11 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
39013905
return ret;
39023906
}
39033907

3908+
if (hidpp->quirks & HIDPP_QUIRK_RESET_HI_RES_SCROLL) {
3909+
if (last_online == 0 && hidpp->battery.online == 1)
3910+
schedule_work(&hidpp->reset_hi_res_work);
3911+
}
3912+
39043913
if (hidpp->quirks & HIDPP_QUIRK_HIDPP_WHEELS) {
39053914
ret = hidpp10_wheel_raw_event(hidpp, data, size);
39063915
if (ret != 0)
@@ -4274,6 +4283,13 @@ static void hidpp_connect_event(struct work_struct *work)
42744283
hidpp->delayed_input = input;
42754284
}
42764285

4286+
static void hidpp_reset_hi_res_handler(struct work_struct *work)
4287+
{
4288+
struct hidpp_device *hidpp = container_of(work, struct hidpp_device, reset_hi_res_work);
4289+
4290+
hi_res_scroll_enable(hidpp);
4291+
}
4292+
42774293
static DEVICE_ATTR(builtin_power_supply, 0000, NULL, NULL);
42784294

42794295
static struct attribute *sysfs_attrs[] = {
@@ -4404,6 +4420,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
44044420
}
44054421

44064422
INIT_WORK(&hidpp->work, hidpp_connect_event);
4423+
INIT_WORK(&hidpp->reset_hi_res_work, hidpp_reset_hi_res_handler);
44074424
mutex_init(&hidpp->send_mutex);
44084425
init_waitqueue_head(&hidpp->wait);
44094426

@@ -4499,6 +4516,7 @@ static void hidpp_remove(struct hid_device *hdev)
44994516

45004517
hid_hw_stop(hdev);
45014518
cancel_work_sync(&hidpp->work);
4519+
cancel_work_sync(&hidpp->reset_hi_res_work);
45024520
mutex_destroy(&hidpp->send_mutex);
45034521
}
45044522

@@ -4546,6 +4564,9 @@ static const struct hid_device_id hidpp_devices[] = {
45464564
{ /* Keyboard MX5500 (Bluetooth-receiver in HID proxy mode) */
45474565
LDJ_DEVICE(0xb30b),
45484566
.driver_data = HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS },
4567+
{ /* Logitech G502 Lightspeed Wireless Gaming Mouse */
4568+
LDJ_DEVICE(0x407f),
4569+
.driver_data = HIDPP_QUIRK_RESET_HI_RES_SCROLL },
45494570

45504571
{ LDJ_DEVICE(HID_ANY_ID) },
45514572

drivers/hid/hid-multitouch.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ enum report_mode {
9494
TOUCHPAD_REPORT_ALL = TOUCHPAD_REPORT_BUTTONS | TOUCHPAD_REPORT_CONTACTS,
9595
};
9696

97-
#define MT_IO_FLAGS_RUNNING 0
98-
#define MT_IO_FLAGS_ACTIVE_SLOTS 1
99-
#define MT_IO_FLAGS_PENDING_SLOTS 2
97+
#define MT_IO_SLOTS_MASK GENMASK(7, 0) /* reserve first 8 bits for slot tracking */
98+
#define MT_IO_FLAGS_RUNNING 32
10099

101100
static const bool mtrue = true; /* default for true */
102101
static const bool mfalse; /* default for false */
@@ -172,7 +171,11 @@ struct mt_device {
172171
struct timer_list release_timer; /* to release sticky fingers */
173172
struct hid_haptic_device *haptic; /* haptic related configuration */
174173
struct hid_device *hdev; /* hid_device we're attached to */
175-
unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */
174+
unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_RUNNING)
175+
* first 8 bits are reserved for keeping the slot
176+
* states, this is fine because we only support up
177+
* to 250 slots (MT_MAX_MAXCONTACT)
178+
*/
176179
__u8 inputmode_value; /* InputMode HID feature value */
177180
__u8 maxcontacts;
178181
bool is_buttonpad; /* is this device a button pad? */
@@ -986,6 +989,7 @@ static void mt_release_pending_palms(struct mt_device *td,
986989

987990
for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) {
988991
clear_bit(slotnum, app->pending_palm_slots);
992+
clear_bit(slotnum, &td->mt_io_flags);
989993

990994
input_mt_slot(input, slotnum);
991995
input_mt_report_slot_inactive(input);
@@ -1019,12 +1023,6 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
10191023
app->left_button_state = 0;
10201024
if (td->is_haptic_touchpad)
10211025
hid_haptic_pressure_reset(td->haptic);
1022-
1023-
if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags))
1024-
set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
1025-
else
1026-
clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags);
1027-
clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags);
10281026
}
10291027

10301028
static int mt_compute_timestamp(struct mt_application *app, __s32 value)
@@ -1202,7 +1200,9 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,
12021200
input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
12031201
input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
12041202

1205-
set_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags);
1203+
set_bit(slotnum, &td->mt_io_flags);
1204+
} else {
1205+
clear_bit(slotnum, &td->mt_io_flags);
12061206
}
12071207

12081208
return 0;
@@ -1337,7 +1337,7 @@ static void mt_touch_report(struct hid_device *hid,
13371337
* defect.
13381338
*/
13391339
if (app->quirks & MT_QUIRK_STICKY_FINGERS) {
1340-
if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags))
1340+
if (td->mt_io_flags & MT_IO_SLOTS_MASK)
13411341
mod_timer(&td->release_timer,
13421342
jiffies + msecs_to_jiffies(100));
13431343
else
@@ -1742,6 +1742,7 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
17421742
case HID_CP_CONSUMER_CONTROL:
17431743
case HID_GD_WIRELESS_RADIO_CTLS:
17441744
case HID_GD_SYSTEM_MULTIAXIS:
1745+
case HID_DG_PEN:
17451746
/* already handled by hid core */
17461747
break;
17471748
case HID_DG_TOUCHSCREEN:
@@ -1813,6 +1814,7 @@ static void mt_release_contacts(struct hid_device *hid)
18131814
for (i = 0; i < mt->num_slots; i++) {
18141815
input_mt_slot(input_dev, i);
18151816
input_mt_report_slot_inactive(input_dev);
1817+
clear_bit(i, &td->mt_io_flags);
18161818
}
18171819
input_mt_sync_frame(input_dev);
18181820
input_sync(input_dev);
@@ -1835,7 +1837,7 @@ static void mt_expired_timeout(struct timer_list *t)
18351837
*/
18361838
if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
18371839
return;
1838-
if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags))
1840+
if (td->mt_io_flags & MT_IO_SLOTS_MASK)
18391841
mt_release_contacts(hdev);
18401842
clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
18411843
}

drivers/hid/hid-nintendo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,10 +1455,10 @@ static void joycon_parse_imu_report(struct joycon_ctlr *ctlr,
14551455
ctlr->imu_avg_delta_ms;
14561456
ctlr->imu_timestamp_us += 1000 * ctlr->imu_avg_delta_ms;
14571457
if (dropped_pkts > JC_IMU_DROPPED_PKT_WARNING) {
1458-
hid_warn(ctlr->hdev,
1458+
hid_warn_ratelimited(ctlr->hdev,
14591459
"compensating for %u dropped IMU reports\n",
14601460
dropped_pkts);
1461-
hid_warn(ctlr->hdev,
1461+
hid_warn_ratelimited(ctlr->hdev,
14621462
"delta=%u avg_delta=%u\n",
14631463
delta, ctlr->imu_avg_delta_ms);
14641464
}
@@ -2420,7 +2420,7 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
24202420
struct joycon_input_report *report;
24212421

24222422
req.subcmd_id = JC_SUBCMD_REQ_DEV_INFO;
2423-
ret = joycon_send_subcmd(ctlr, &req, 0, HZ);
2423+
ret = joycon_send_subcmd(ctlr, &req, 0, 2 * HZ);
24242424
if (ret) {
24252425
hid_err(ctlr->hdev, "Failed to get joycon info; ret=%d\n", ret);
24262426
return ret;

drivers/hid/hid-quirks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static const struct hid_device_id hid_quirks[] = {
5757
{ HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE), HID_QUIRK_NOGET },
5858
{ HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS), HID_QUIRK_NOGET },
5959
{ HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_THROTTLE), HID_QUIRK_NOGET },
60+
{ HID_USB_DEVICE(USB_VENDOR_ID_COOLER_MASTER, USB_DEVICE_ID_COOLER_MASTER_MICE_DONGLE), HID_QUIRK_ALWAYS_POLL },
6061
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB), HID_QUIRK_NO_INIT_REPORTS },
6162
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
6263
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB), HID_QUIRK_NO_INIT_REPORTS },
@@ -206,6 +207,7 @@ static const struct hid_device_id hid_quirks[] = {
206207
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_KNA5), HID_QUIRK_MULTI_INPUT },
207208
{ HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_TWA60), HID_QUIRK_MULTI_INPUT },
208209
{ HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_WP5540), HID_QUIRK_MULTI_INPUT },
210+
{ HID_USB_DEVICE(USB_VENDOR_ID_VRS, USB_DEVICE_ID_VRS_R295), HID_QUIRK_ALWAYS_POLL },
209211
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH), HID_QUIRK_MULTI_INPUT },
210212
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH), HID_QUIRK_MULTI_INPUT },
211213
{ HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET), HID_QUIRK_MULTI_INPUT },

drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static void quicki2c_dma_adv_enable(struct quicki2c_device *qcdev)
466466
dev_warn(qcdev->dev,
467467
"Max frame size is smaller than hid max input length!");
468468
thc_i2c_set_rx_max_size(qcdev->thc_hw,
469-
le16_to_cpu(qcdev->i2c_max_frame_size));
469+
qcdev->i2c_max_frame_size);
470470
}
471471
thc_i2c_rx_max_size_enable(qcdev->thc_hw, true);
472472
}

0 commit comments

Comments
 (0)