Skip to content

Commit 5e33554

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID fixes from Jiri Kosina: - functional regression fix for sensor-hub driver from Hans de Goede - stop doing device reset for i2c-hid devices, which unbreaks some of them (and is in line with the specification), from Kai-Heng Feng - error handling fix for hid-core from Gustavo A. R. Silva - functional regression fix for some Elan panels from Benjamin Tissoires - a few new device ID additions and misc small fixes * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: i2c-hid: Don't reset device upon system resume HID: sensor-hub: Restore fixup for Lenovo ThinkPad Helix 2 sensor hub report HID: core: fix NULL pointer dereference HID: core: fix grouping by application HID: multitouch: fix Elan panels with 2 input modes declaration HID: hid-saitek: Add device ID for RAT 7 Contagion HID: core: fix memory leak on probe HID: input: fix leaking custom input node name HID: add support for Apple Magic Keyboards HID: i2c-hid: Fix flooded incomplete report after S3 on Rayd touchscreen HID: intel-ish-hid: Enable Sunrise Point-H ish driver
2 parents 28a0ea7 + 52cf93e commit 5e33554

File tree

11 files changed

+70
-13
lines changed

11 files changed

+70
-13
lines changed

drivers/hid/hid-apple.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
335335
struct hid_field *field, struct hid_usage *usage,
336336
unsigned long **bit, int *max)
337337
{
338-
if (usage->hid == (HID_UP_CUSTOM | 0x0003)) {
338+
if (usage->hid == (HID_UP_CUSTOM | 0x0003) ||
339+
usage->hid == (HID_UP_MSVENDOR | 0x0003)) {
339340
/* The fn key on Apple USB keyboards */
340341
set_bit(EV_REP, hi->input->evbit);
341342
hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN);
@@ -472,6 +473,12 @@ static const struct hid_device_id apple_devices[] = {
472473
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
473474
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
474475
.driver_data = APPLE_HAS_FN },
476+
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI),
477+
.driver_data = APPLE_HAS_FN },
478+
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
479+
.driver_data = APPLE_HAS_FN },
480+
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI),
481+
.driver_data = APPLE_HAS_FN },
475482
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
476483
.driver_data = APPLE_HAS_FN },
477484
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),

drivers/hid/hid-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device)
10001000
parser = vzalloc(sizeof(struct hid_parser));
10011001
if (!parser) {
10021002
ret = -ENOMEM;
1003-
goto err;
1003+
goto alloc_err;
10041004
}
10051005

10061006
parser->device = device;
@@ -1039,6 +1039,7 @@ int hid_open_report(struct hid_device *device)
10391039
hid_err(device, "unbalanced delimiter at end of report description\n");
10401040
goto err;
10411041
}
1042+
kfree(parser->collection_stack);
10421043
vfree(parser);
10431044
device->status |= HID_STAT_PARSED;
10441045
return 0;
@@ -1047,6 +1048,8 @@ int hid_open_report(struct hid_device *device)
10471048

10481049
hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
10491050
err:
1051+
kfree(parser->collection_stack);
1052+
alloc_err:
10501053
vfree(parser);
10511054
hid_close_report(device);
10521055
return ret;

drivers/hid/hid-ids.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
#define USB_DEVICE_ID_ANTON_TOUCH_PAD 0x3101
8989

9090
#define USB_VENDOR_ID_APPLE 0x05ac
91+
#define BT_VENDOR_ID_APPLE 0x004c
9192
#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
9293
#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d
9394
#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e
@@ -157,6 +158,7 @@
157158
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
158159
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257
159160
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI 0x0267
161+
#define USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI 0x026c
160162
#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
161163
#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
162164
#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
@@ -528,9 +530,6 @@
528530
#define I2C_VENDOR_ID_HANTICK 0x0911
529531
#define I2C_PRODUCT_ID_HANTICK_5288 0x5288
530532

531-
#define I2C_VENDOR_ID_RAYD 0x2386
532-
#define I2C_PRODUCT_ID_RAYD_3118 0x3118
533-
534533
#define USB_VENDOR_ID_HANWANG 0x0b57
535534
#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000
536535
#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff
@@ -950,6 +949,7 @@
950949
#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
951950
#define USB_DEVICE_ID_SAITEK_PS1000 0x0621
952951
#define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb
952+
#define USB_DEVICE_ID_SAITEK_RAT7_CONTAGION 0x0ccd
953953
#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7
954954
#define USB_DEVICE_ID_SAITEK_RAT9 0x0cfa
955955
#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0

drivers/hid/hid-input.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,
15821582
input_dev->dev.parent = &hid->dev;
15831583

15841584
hidinput->input = input_dev;
1585+
hidinput->application = application;
15851586
list_add_tail(&hidinput->list, &hid->inputs);
15861587

15871588
INIT_LIST_HEAD(&hidinput->reports);
@@ -1677,8 +1678,7 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
16771678
struct hid_input *hidinput;
16781679

16791680
list_for_each_entry(hidinput, &hid->inputs, list) {
1680-
if (hidinput->report &&
1681-
hidinput->report->application == report->application)
1681+
if (hidinput->application == report->application)
16821682
return hidinput;
16831683
}
16841684

@@ -1815,6 +1815,7 @@ void hidinput_disconnect(struct hid_device *hid)
18151815
input_unregister_device(hidinput->input);
18161816
else
18171817
input_free_device(hidinput->input);
1818+
kfree(hidinput->name);
18181819
kfree(hidinput);
18191820
}
18201821

drivers/hid/hid-multitouch.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,8 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
13751375
struct hid_usage *usage,
13761376
enum latency_mode latency,
13771377
bool surface_switch,
1378-
bool button_switch)
1378+
bool button_switch,
1379+
bool *inputmode_found)
13791380
{
13801381
struct mt_device *td = hid_get_drvdata(hdev);
13811382
struct mt_class *cls = &td->mtclass;
@@ -1387,6 +1388,14 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
13871388

13881389
switch (usage->hid) {
13891390
case HID_DG_INPUTMODE:
1391+
/*
1392+
* Some elan panels wrongly declare 2 input mode features,
1393+
* and silently ignore when we set the value in the second
1394+
* field. Skip the second feature and hope for the best.
1395+
*/
1396+
if (*inputmode_found)
1397+
return false;
1398+
13901399
if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) {
13911400
report_len = hid_report_len(report);
13921401
buf = hid_alloc_report_buf(report, GFP_KERNEL);
@@ -1402,6 +1411,7 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,
14021411
}
14031412

14041413
field->value[index] = td->inputmode_value;
1414+
*inputmode_found = true;
14051415
return true;
14061416

14071417
case HID_DG_CONTACTMAX:
@@ -1439,6 +1449,7 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency,
14391449
struct hid_usage *usage;
14401450
int i, j;
14411451
bool update_report;
1452+
bool inputmode_found = false;
14421453

14431454
rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
14441455
list_for_each_entry(rep, &rep_enum->report_list, list) {
@@ -1457,7 +1468,8 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency,
14571468
usage,
14581469
latency,
14591470
surface_switch,
1460-
button_switch))
1471+
button_switch,
1472+
&inputmode_found))
14611473
update_report = true;
14621474
}
14631475
}
@@ -1685,6 +1697,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
16851697
*/
16861698
hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
16871699

1700+
if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
1701+
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
1702+
16881703
timer_setup(&td->release_timer, mt_expired_timeout, 0);
16891704

16901705
ret = hid_parse(hdev);

drivers/hid/hid-saitek.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ static const struct hid_device_id saitek_devices[] = {
183183
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
184184
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7),
185185
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
186+
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_CONTAGION),
187+
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
186188
{ HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT9),
187189
.driver_data = SAITEK_RELEASE_MODE_RAT7 },
188190
{ HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9),

drivers/hid/hid-sensor-hub.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,28 @@ void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
579579
}
580580
EXPORT_SYMBOL_GPL(sensor_hub_device_close);
581581

582+
static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
583+
unsigned int *rsize)
584+
{
585+
/*
586+
* Checks if the report descriptor of Thinkpad Helix 2 has a logical
587+
* minimum for magnetic flux axis greater than the maximum.
588+
*/
589+
if (hdev->product == USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA &&
590+
*rsize == 2558 && rdesc[913] == 0x17 && rdesc[914] == 0x40 &&
591+
rdesc[915] == 0x81 && rdesc[916] == 0x08 &&
592+
rdesc[917] == 0x00 && rdesc[918] == 0x27 &&
593+
rdesc[921] == 0x07 && rdesc[922] == 0x00) {
594+
/* Sets negative logical minimum for mag x, y and z */
595+
rdesc[914] = rdesc[935] = rdesc[956] = 0xc0;
596+
rdesc[915] = rdesc[936] = rdesc[957] = 0x7e;
597+
rdesc[916] = rdesc[937] = rdesc[958] = 0xf7;
598+
rdesc[917] = rdesc[938] = rdesc[959] = 0xff;
599+
}
600+
601+
return rdesc;
602+
}
603+
582604
static int sensor_hub_probe(struct hid_device *hdev,
583605
const struct hid_device_id *id)
584606
{
@@ -743,6 +765,7 @@ static struct hid_driver sensor_hub_driver = {
743765
.probe = sensor_hub_probe,
744766
.remove = sensor_hub_remove,
745767
.raw_event = sensor_hub_raw_event,
768+
.report_fixup = sensor_hub_report_fixup,
746769
#ifdef CONFIG_PM
747770
.suspend = sensor_hub_suspend,
748771
.resume = sensor_hub_resume,

drivers/hid/i2c-hid/i2c-hid.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ static const struct i2c_hid_quirks {
170170
I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
171171
{ I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
172172
I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
173-
{ I2C_VENDOR_ID_RAYD, I2C_PRODUCT_ID_RAYD_3118,
174-
I2C_HID_QUIRK_RESEND_REPORT_DESCR },
175173
{ USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH,
176174
I2C_HID_QUIRK_RESEND_REPORT_DESCR },
177175
{ 0, 0 }
@@ -1235,11 +1233,16 @@ static int i2c_hid_resume(struct device *dev)
12351233
pm_runtime_enable(dev);
12361234

12371235
enable_irq(client->irq);
1238-
ret = i2c_hid_hwreset(client);
1236+
1237+
/* Instead of resetting device, simply powers the device on. This
1238+
* solves "incomplete reports" on Raydium devices 2386:3118 and
1239+
* 2386:4B33
1240+
*/
1241+
ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
12391242
if (ret)
12401243
return ret;
12411244

1242-
/* RAYDIUM device (2386:3118) need to re-send report descr cmd
1245+
/* Some devices need to re-send report descr cmd
12431246
* after resume, after this it will be back normal.
12441247
* otherwise it issues too many incomplete reports.
12451248
*/

drivers/hid/intel-ish-hid/ipc/hw-ish.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#define CNL_Ax_DEVICE_ID 0x9DFC
3030
#define GLK_Ax_DEVICE_ID 0x31A2
3131
#define CNL_H_DEVICE_ID 0xA37C
32+
#define SPT_H_DEVICE_ID 0xA135
3233

3334
#define REVISION_ID_CHT_A0 0x6
3435
#define REVISION_ID_CHT_Ax_SI 0x0

drivers/hid/intel-ish-hid/ipc/pci-ish.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static const struct pci_device_id ish_pci_tbl[] = {
3838
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_Ax_DEVICE_ID)},
3939
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, GLK_Ax_DEVICE_ID)},
4040
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, CNL_H_DEVICE_ID)},
41+
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, SPT_H_DEVICE_ID)},
4142
{0, }
4243
};
4344
MODULE_DEVICE_TABLE(pci, ish_pci_tbl);

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ struct hid_input {
526526
const char *name;
527527
bool registered;
528528
struct list_head reports; /* the list of reports */
529+
unsigned int application; /* application usage for this input */
529530
};
530531

531532
enum hid_type {

0 commit comments

Comments
 (0)