Skip to content

Commit 19fbf67

Browse files
committed
Merge tag 'for-linus-2023100502' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
Pull HID fixes from Jiri Kosina: - power management fix for intel-ish-hid (Srinivas Pandruvada) - power management fix for hid-nintendo (Martino Fontana) - error handling fixes for nvidia-shield (Christophe JAILLET) - memory leak fix for hid-sony (Christophe JAILLET) - fix for slab out-of-bound write in hid-holtek (Ma Ke) - other assorted smaller fixes and device ID / quirk entry additions * tag 'for-linus-2023100502' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: HID: Add quirk to ignore the touchscreen battery on HP ENVY 15-eu0556ng HID: intel-ish-hid: ipc: Disable and reenable ACPI GPE bit HID: sony: remove duplicate NULL check before calling usb_free_urb() HID: nintendo: reinitialize USB Pro Controller after resuming from suspend HID: nvidia-shield: Fix some missing function calls() in the probe error handling path HID: nvidia-shield: Fix a missing led_classdev_unregister() in the probe error handling path HID: multitouch: Add required quirk for Synaptics 0xcd7e device HID: nvidia-shield: Select POWER_SUPPLY Kconfig option HID: holtek: fix slab-out-of-bounds Write in holtek_kbd_input_event HID: nvidia-shield: add LEDS_CLASS dependency HID: logitech-hidpp: Add Bluetooth ID for the Logitech M720 Triathlon mouse HID: steelseries: Fix signedness bug in steelseries_headset_arctis_1_fetch_battery() HID: sony: Fix a potential memory leak in sony_probe()
2 parents f291209 + b009aa3 commit 19fbf67

File tree

11 files changed

+135
-76
lines changed

11 files changed

+135
-76
lines changed

drivers/hid/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,8 @@ config HID_NVIDIA_SHIELD
799799
tristate "NVIDIA SHIELD devices"
800800
depends on USB_HID
801801
depends on BT_HIDP
802+
depends on LEDS_CLASS
803+
select POWER_SUPPLY
802804
help
803805
Support for NVIDIA SHIELD accessories.
804806

drivers/hid/hid-holtek-kbd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
130130
return -ENODEV;
131131

132132
boot_hid = usb_get_intfdata(boot_interface);
133+
if (list_empty(&boot_hid->inputs)) {
134+
hid_err(hid, "no inputs found\n");
135+
return -ENODEV;
136+
}
133137
boot_hid_input = list_first_entry(&boot_hid->inputs,
134138
struct hid_input, list);
135139

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@
425425
#define I2C_DEVICE_ID_HP_SPECTRE_X360_13T_AW100 0x29F5
426426
#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V1 0x2BED
427427
#define I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2 0x2BEE
428+
#define I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG 0x2D02
428429

429430
#define USB_VENDOR_ID_ELECOM 0x056e
430431
#define USB_DEVICE_ID_ELECOM_BM084 0x0061

drivers/hid/hid-input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ static const struct hid_device_id hid_battery_quirks[] = {
409409
HID_BATTERY_QUIRK_IGNORE },
410410
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_14T_EA100_V2),
411411
HID_BATTERY_QUIRK_IGNORE },
412+
{ HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_ENVY_X360_15_EU0556NG),
413+
HID_BATTERY_QUIRK_IGNORE },
412414
{}
413415
};
414416

drivers/hid/hid-logitech-hidpp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,6 +4677,8 @@ static const struct hid_device_id hidpp_devices[] = {
46774677
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb008) },
46784678
{ /* MX Master mouse over Bluetooth */
46794679
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012) },
4680+
{ /* M720 Triathlon mouse over Bluetooth */
4681+
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb015) },
46804682
{ /* MX Ergo trackball over Bluetooth */
46814683
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01d) },
46824684
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e) },

drivers/hid/hid-multitouch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,10 @@ static const struct hid_device_id mt_devices[] = {
21442144
USB_DEVICE_ID_MTP_STM)},
21452145

21462146
/* Synaptics devices */
2147+
{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
2148+
HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
2149+
USB_VENDOR_ID_SYNAPTICS, 0xcd7e) },
2150+
21472151
{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
21482152
HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
21492153
USB_VENDOR_ID_SYNAPTICS, 0xce08) },

drivers/hid/hid-nintendo.c

Lines changed: 103 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,9 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
20882088
struct joycon_input_report *report;
20892089

20902090
req.subcmd_id = JC_SUBCMD_REQ_DEV_INFO;
2091+
mutex_lock(&ctlr->output_mutex);
20912092
ret = joycon_send_subcmd(ctlr, &req, 0, HZ);
2093+
mutex_unlock(&ctlr->output_mutex);
20922094
if (ret) {
20932095
hid_err(ctlr->hdev, "Failed to get joycon info; ret=%d\n", ret);
20942096
return ret;
@@ -2117,6 +2119,85 @@ static int joycon_read_info(struct joycon_ctlr *ctlr)
21172119
return 0;
21182120
}
21192121

2122+
static int joycon_init(struct hid_device *hdev)
2123+
{
2124+
struct joycon_ctlr *ctlr = hid_get_drvdata(hdev);
2125+
int ret = 0;
2126+
2127+
mutex_lock(&ctlr->output_mutex);
2128+
/* if handshake command fails, assume ble pro controller */
2129+
if ((jc_type_is_procon(ctlr) || jc_type_is_chrggrip(ctlr)) &&
2130+
!joycon_send_usb(ctlr, JC_USB_CMD_HANDSHAKE, HZ)) {
2131+
hid_dbg(hdev, "detected USB controller\n");
2132+
/* set baudrate for improved latency */
2133+
ret = joycon_send_usb(ctlr, JC_USB_CMD_BAUDRATE_3M, HZ);
2134+
if (ret) {
2135+
hid_err(hdev, "Failed to set baudrate; ret=%d\n", ret);
2136+
goto out_unlock;
2137+
}
2138+
/* handshake */
2139+
ret = joycon_send_usb(ctlr, JC_USB_CMD_HANDSHAKE, HZ);
2140+
if (ret) {
2141+
hid_err(hdev, "Failed handshake; ret=%d\n", ret);
2142+
goto out_unlock;
2143+
}
2144+
/*
2145+
* Set no timeout (to keep controller in USB mode).
2146+
* This doesn't send a response, so ignore the timeout.
2147+
*/
2148+
joycon_send_usb(ctlr, JC_USB_CMD_NO_TIMEOUT, HZ/10);
2149+
} else if (jc_type_is_chrggrip(ctlr)) {
2150+
hid_err(hdev, "Failed charging grip handshake\n");
2151+
ret = -ETIMEDOUT;
2152+
goto out_unlock;
2153+
}
2154+
2155+
/* get controller calibration data, and parse it */
2156+
ret = joycon_request_calibration(ctlr);
2157+
if (ret) {
2158+
/*
2159+
* We can function with default calibration, but it may be
2160+
* inaccurate. Provide a warning, and continue on.
2161+
*/
2162+
hid_warn(hdev, "Analog stick positions may be inaccurate\n");
2163+
}
2164+
2165+
/* get IMU calibration data, and parse it */
2166+
ret = joycon_request_imu_calibration(ctlr);
2167+
if (ret) {
2168+
/*
2169+
* We can function with default calibration, but it may be
2170+
* inaccurate. Provide a warning, and continue on.
2171+
*/
2172+
hid_warn(hdev, "Unable to read IMU calibration data\n");
2173+
}
2174+
2175+
/* Set the reporting mode to 0x30, which is the full report mode */
2176+
ret = joycon_set_report_mode(ctlr);
2177+
if (ret) {
2178+
hid_err(hdev, "Failed to set report mode; ret=%d\n", ret);
2179+
goto out_unlock;
2180+
}
2181+
2182+
/* Enable rumble */
2183+
ret = joycon_enable_rumble(ctlr);
2184+
if (ret) {
2185+
hid_err(hdev, "Failed to enable rumble; ret=%d\n", ret);
2186+
goto out_unlock;
2187+
}
2188+
2189+
/* Enable the IMU */
2190+
ret = joycon_enable_imu(ctlr);
2191+
if (ret) {
2192+
hid_err(hdev, "Failed to enable the IMU; ret=%d\n", ret);
2193+
goto out_unlock;
2194+
}
2195+
2196+
out_unlock:
2197+
mutex_unlock(&ctlr->output_mutex);
2198+
return ret;
2199+
}
2200+
21202201
/* Common handler for parsing inputs */
21212202
static int joycon_ctlr_read_handler(struct joycon_ctlr *ctlr, u8 *data,
21222203
int size)
@@ -2248,85 +2329,19 @@ static int nintendo_hid_probe(struct hid_device *hdev,
22482329

22492330
hid_device_io_start(hdev);
22502331

2251-
/* Initialize the controller */
2252-
mutex_lock(&ctlr->output_mutex);
2253-
/* if handshake command fails, assume ble pro controller */
2254-
if ((jc_type_is_procon(ctlr) || jc_type_is_chrggrip(ctlr)) &&
2255-
!joycon_send_usb(ctlr, JC_USB_CMD_HANDSHAKE, HZ)) {
2256-
hid_dbg(hdev, "detected USB controller\n");
2257-
/* set baudrate for improved latency */
2258-
ret = joycon_send_usb(ctlr, JC_USB_CMD_BAUDRATE_3M, HZ);
2259-
if (ret) {
2260-
hid_err(hdev, "Failed to set baudrate; ret=%d\n", ret);
2261-
goto err_mutex;
2262-
}
2263-
/* handshake */
2264-
ret = joycon_send_usb(ctlr, JC_USB_CMD_HANDSHAKE, HZ);
2265-
if (ret) {
2266-
hid_err(hdev, "Failed handshake; ret=%d\n", ret);
2267-
goto err_mutex;
2268-
}
2269-
/*
2270-
* Set no timeout (to keep controller in USB mode).
2271-
* This doesn't send a response, so ignore the timeout.
2272-
*/
2273-
joycon_send_usb(ctlr, JC_USB_CMD_NO_TIMEOUT, HZ/10);
2274-
} else if (jc_type_is_chrggrip(ctlr)) {
2275-
hid_err(hdev, "Failed charging grip handshake\n");
2276-
ret = -ETIMEDOUT;
2277-
goto err_mutex;
2278-
}
2279-
2280-
/* get controller calibration data, and parse it */
2281-
ret = joycon_request_calibration(ctlr);
2332+
ret = joycon_init(hdev);
22822333
if (ret) {
2283-
/*
2284-
* We can function with default calibration, but it may be
2285-
* inaccurate. Provide a warning, and continue on.
2286-
*/
2287-
hid_warn(hdev, "Analog stick positions may be inaccurate\n");
2288-
}
2289-
2290-
/* get IMU calibration data, and parse it */
2291-
ret = joycon_request_imu_calibration(ctlr);
2292-
if (ret) {
2293-
/*
2294-
* We can function with default calibration, but it may be
2295-
* inaccurate. Provide a warning, and continue on.
2296-
*/
2297-
hid_warn(hdev, "Unable to read IMU calibration data\n");
2298-
}
2299-
2300-
/* Set the reporting mode to 0x30, which is the full report mode */
2301-
ret = joycon_set_report_mode(ctlr);
2302-
if (ret) {
2303-
hid_err(hdev, "Failed to set report mode; ret=%d\n", ret);
2304-
goto err_mutex;
2305-
}
2306-
2307-
/* Enable rumble */
2308-
ret = joycon_enable_rumble(ctlr);
2309-
if (ret) {
2310-
hid_err(hdev, "Failed to enable rumble; ret=%d\n", ret);
2311-
goto err_mutex;
2312-
}
2313-
2314-
/* Enable the IMU */
2315-
ret = joycon_enable_imu(ctlr);
2316-
if (ret) {
2317-
hid_err(hdev, "Failed to enable the IMU; ret=%d\n", ret);
2318-
goto err_mutex;
2334+
hid_err(hdev, "Failed to initialize controller; ret=%d\n", ret);
2335+
goto err_close;
23192336
}
23202337

23212338
ret = joycon_read_info(ctlr);
23222339
if (ret) {
23232340
hid_err(hdev, "Failed to retrieve controller info; ret=%d\n",
23242341
ret);
2325-
goto err_mutex;
2342+
goto err_close;
23262343
}
23272344

2328-
mutex_unlock(&ctlr->output_mutex);
2329-
23302345
/* Initialize the leds */
23312346
ret = joycon_leds_create(ctlr);
23322347
if (ret) {
@@ -2352,8 +2367,6 @@ static int nintendo_hid_probe(struct hid_device *hdev,
23522367
hid_dbg(hdev, "probe - success\n");
23532368
return 0;
23542369

2355-
err_mutex:
2356-
mutex_unlock(&ctlr->output_mutex);
23572370
err_close:
23582371
hid_hw_close(hdev);
23592372
err_stop:
@@ -2383,6 +2396,20 @@ static void nintendo_hid_remove(struct hid_device *hdev)
23832396
hid_hw_stop(hdev);
23842397
}
23852398

2399+
#ifdef CONFIG_PM
2400+
2401+
static int nintendo_hid_resume(struct hid_device *hdev)
2402+
{
2403+
int ret = joycon_init(hdev);
2404+
2405+
if (ret)
2406+
hid_err(hdev, "Failed to restore controller after resume");
2407+
2408+
return ret;
2409+
}
2410+
2411+
#endif
2412+
23862413
static const struct hid_device_id nintendo_hid_devices[] = {
23872414
{ HID_USB_DEVICE(USB_VENDOR_ID_NINTENDO,
23882415
USB_DEVICE_ID_NINTENDO_PROCON) },
@@ -2404,6 +2431,10 @@ static struct hid_driver nintendo_hid_driver = {
24042431
.probe = nintendo_hid_probe,
24052432
.remove = nintendo_hid_remove,
24062433
.raw_event = nintendo_hid_event,
2434+
2435+
#ifdef CONFIG_PM
2436+
.resume = nintendo_hid_resume,
2437+
#endif
24072438
};
24082439
module_hid_driver(nintendo_hid_driver);
24092440

drivers/hid/hid-nvidia-shield.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ static inline int thunderstrike_led_create(struct thunderstrike *ts)
801801
led->name = devm_kasprintf(&ts->base.hdev->dev, GFP_KERNEL,
802802
"thunderstrike%d:blue:led", ts->id);
803803
led->max_brightness = 1;
804-
led->flags = LED_CORE_SUSPENDRESUME;
804+
led->flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
805805
led->brightness_get = &thunderstrike_led_get_brightness;
806806
led->brightness_set = &thunderstrike_led_set_brightness;
807807

@@ -1058,7 +1058,7 @@ static int shield_probe(struct hid_device *hdev, const struct hid_device_id *id)
10581058
ret = hid_hw_start(hdev, HID_CONNECT_HIDINPUT);
10591059
if (ret) {
10601060
hid_err(hdev, "Failed to start HID device\n");
1061-
goto err_haptics;
1061+
goto err_ts_create;
10621062
}
10631063

10641064
ret = hid_hw_open(hdev);
@@ -1073,9 +1073,12 @@ static int shield_probe(struct hid_device *hdev, const struct hid_device_id *id)
10731073

10741074
err_stop:
10751075
hid_hw_stop(hdev);
1076-
err_haptics:
1076+
err_ts_create:
1077+
power_supply_unregister(ts->base.battery_dev.psy);
10771078
if (ts->haptics_dev)
10781079
input_unregister_device(ts->haptics_dev);
1080+
led_classdev_unregister(&ts->led_dev);
1081+
ida_free(&thunderstrike_ida, ts->id);
10791082
return ret;
10801083
}
10811084

drivers/hid/hid-sony.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
21552155
return ret;
21562156

21572157
err:
2158+
usb_free_urb(sc->ghl_urb);
2159+
21582160
hid_hw_stop(hdev);
21592161
return ret;
21602162
}

drivers/hid/hid-steelseries.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static int steelseries_headset_arctis_1_fetch_battery(struct hid_device *hdev)
390390
ret = hid_hw_raw_request(hdev, arctis_1_battery_request[0],
391391
write_buf, sizeof(arctis_1_battery_request),
392392
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
393-
if (ret < sizeof(arctis_1_battery_request)) {
393+
if (ret < (int)sizeof(arctis_1_battery_request)) {
394394
hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret);
395395
ret = -ENODATA;
396396
}

0 commit comments

Comments
 (0)