Skip to content

Commit fd73788

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.14/core' into for-linus
- device unbinding locking fix from Dmitry Torokhov - support for programmable buttons (mapping to KEY_MACRO# event codes) from Thomas Weißschuh - various other small fixes and code style improvements
2 parents 5a94296 + bcfa8d1 commit fd73788

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

drivers/hid/hid-core.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev)
23062306
{
23072307
struct hid_device *hdev = to_hid_device(dev);
23082308
struct hid_driver *hdrv;
2309-
int ret = 0;
23102309

2311-
if (down_interruptible(&hdev->driver_input_lock)) {
2312-
ret = -EINTR;
2313-
goto end;
2314-
}
2310+
down(&hdev->driver_input_lock);
23152311
hdev->io_started = false;
23162312

23172313
hdrv = hdev->driver;
@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev)
23262322

23272323
if (!hdev->io_started)
23282324
up(&hdev->driver_input_lock);
2329-
end:
2330-
return ret;
2325+
2326+
return 0;
23312327
}
23322328

23332329
static ssize_t modalias_show(struct device *dev, struct device_attribute *a,

drivers/hid/hid-debug.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
122122
{ 9, 0, "Button" },
123123
{ 10, 0, "Ordinal" },
124124
{ 12, 0, "Consumer" },
125+
{0, 0x003, "ProgrammableButtons"},
125126
{0, 0x238, "HorizontalWheel"},
126127
{ 13, 0, "Digitizers" },
127128
{0, 0x01, "Digitizer"},
@@ -942,6 +943,16 @@ static const char *keys[KEY_MAX + 1] = {
942943
[KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup",
943944
[KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept",
944945
[KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel",
946+
[KEY_MACRO1] = "Macro1", [KEY_MACRO2] = "Macro2", [KEY_MACRO3] = "Macro3",
947+
[KEY_MACRO4] = "Macro4", [KEY_MACRO5] = "Macro5", [KEY_MACRO6] = "Macro6",
948+
[KEY_MACRO7] = "Macro7", [KEY_MACRO8] = "Macro8", [KEY_MACRO9] = "Macro9",
949+
[KEY_MACRO10] = "Macro10", [KEY_MACRO11] = "Macro11", [KEY_MACRO12] = "Macro12",
950+
[KEY_MACRO13] = "Macro13", [KEY_MACRO14] = "Macro14", [KEY_MACRO15] = "Macro15",
951+
[KEY_MACRO16] = "Macro16", [KEY_MACRO17] = "Macro17", [KEY_MACRO18] = "Macro18",
952+
[KEY_MACRO19] = "Macro19", [KEY_MACRO20] = "Macro20", [KEY_MACRO21] = "Macro21",
953+
[KEY_MACRO22] = "Macro22", [KEY_MACRO23] = "Macro23", [KEY_MACRO24] = "Macro24",
954+
[KEY_MACRO25] = "Macro25", [KEY_MACRO26] = "Macro26", [KEY_MACRO27] = "Macro27",
955+
[KEY_MACRO28] = "Macro28", [KEY_MACRO29] = "Macro29", [KEY_MACRO30] = "Macro30",
945956
};
946957

947958
static const char *relatives[REL_MAX + 1] = {

drivers/hid/hid-input.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,16 @@ static void hidinput_update_battery(struct hid_device *dev, int value)
569569
}
570570
#endif /* CONFIG_HID_BATTERY_STRENGTH */
571571

572+
static bool hidinput_field_in_collection(struct hid_device *device, struct hid_field *field,
573+
unsigned int type, unsigned int usage)
574+
{
575+
struct hid_collection *collection;
576+
577+
collection = &device->collection[field->usage->collection_index];
578+
579+
return collection->type == type && collection->usage == usage;
580+
}
581+
572582
static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
573583
struct hid_usage *usage)
574584
{
@@ -634,6 +644,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
634644
else
635645
code += BTN_TRIGGER_HAPPY - 0x10;
636646
break;
647+
case HID_CP_CONSUMER_CONTROL:
648+
if (hidinput_field_in_collection(device, field,
649+
HID_COLLECTION_NAMED_ARRAY,
650+
HID_CP_PROGRAMMABLEBUTTONS)) {
651+
if (code <= 0x1d)
652+
code += KEY_MACRO1;
653+
else
654+
code += BTN_TRIGGER_HAPPY - 0x1e;
655+
} else {
656+
goto ignore;
657+
}
658+
break;
637659
default:
638660
switch (field->physical) {
639661
case HID_GD_MOUSE:
@@ -1318,12 +1340,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
13181340
return;
13191341
}
13201342

1321-
if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */
1343+
if (usage->hid == HID_DG_INVERT) {
13221344
*quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT);
13231345
return;
13241346
}
13251347

1326-
if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */
1348+
if (usage->hid == HID_DG_INRANGE) {
13271349
if (value) {
13281350
input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
13291351
return;
@@ -1333,7 +1355,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
13331355
return;
13341356
}
13351357

1336-
if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */
1358+
if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) {
13371359
int a = field->logical_minimum;
13381360
int b = field->logical_maximum;
13391361
input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));

drivers/hid/usbhid/usbmouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
130130
if (!mouse || !input_dev)
131131
goto fail1;
132132

133-
mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma);
133+
mouse->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &mouse->data_dma);
134134
if (!mouse->data)
135135
goto fail1;
136136

include/linux/hid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct hid_item {
102102
#define HID_COLLECTION_PHYSICAL 0
103103
#define HID_COLLECTION_APPLICATION 1
104104
#define HID_COLLECTION_LOGICAL 2
105+
#define HID_COLLECTION_NAMED_ARRAY 4
105106

106107
/*
107108
* HID report descriptor global item tags

0 commit comments

Comments
 (0)