Commit fd73788c authored by Jiri Kosina's avatar Jiri Kosina

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
parents 5a94296b bcfa8d14
...@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev) ...@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev)
{ {
struct hid_device *hdev = to_hid_device(dev); struct hid_device *hdev = to_hid_device(dev);
struct hid_driver *hdrv; struct hid_driver *hdrv;
int ret = 0;
if (down_interruptible(&hdev->driver_input_lock)) { down(&hdev->driver_input_lock);
ret = -EINTR;
goto end;
}
hdev->io_started = false; hdev->io_started = false;
hdrv = hdev->driver; hdrv = hdev->driver;
...@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev) ...@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev)
if (!hdev->io_started) if (!hdev->io_started)
up(&hdev->driver_input_lock); up(&hdev->driver_input_lock);
end:
return ret; return 0;
} }
static ssize_t modalias_show(struct device *dev, struct device_attribute *a, static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
......
...@@ -122,6 +122,7 @@ static const struct hid_usage_entry hid_usage_table[] = { ...@@ -122,6 +122,7 @@ static const struct hid_usage_entry hid_usage_table[] = {
{ 9, 0, "Button" }, { 9, 0, "Button" },
{ 10, 0, "Ordinal" }, { 10, 0, "Ordinal" },
{ 12, 0, "Consumer" }, { 12, 0, "Consumer" },
{0, 0x003, "ProgrammableButtons"},
{0, 0x238, "HorizontalWheel"}, {0, 0x238, "HorizontalWheel"},
{ 13, 0, "Digitizers" }, { 13, 0, "Digitizers" },
{0, 0x01, "Digitizer"}, {0, 0x01, "Digitizer"},
...@@ -942,6 +943,16 @@ static const char *keys[KEY_MAX + 1] = { ...@@ -942,6 +943,16 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup", [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup",
[KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept", [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept",
[KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel", [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel",
[KEY_MACRO1] = "Macro1", [KEY_MACRO2] = "Macro2", [KEY_MACRO3] = "Macro3",
[KEY_MACRO4] = "Macro4", [KEY_MACRO5] = "Macro5", [KEY_MACRO6] = "Macro6",
[KEY_MACRO7] = "Macro7", [KEY_MACRO8] = "Macro8", [KEY_MACRO9] = "Macro9",
[KEY_MACRO10] = "Macro10", [KEY_MACRO11] = "Macro11", [KEY_MACRO12] = "Macro12",
[KEY_MACRO13] = "Macro13", [KEY_MACRO14] = "Macro14", [KEY_MACRO15] = "Macro15",
[KEY_MACRO16] = "Macro16", [KEY_MACRO17] = "Macro17", [KEY_MACRO18] = "Macro18",
[KEY_MACRO19] = "Macro19", [KEY_MACRO20] = "Macro20", [KEY_MACRO21] = "Macro21",
[KEY_MACRO22] = "Macro22", [KEY_MACRO23] = "Macro23", [KEY_MACRO24] = "Macro24",
[KEY_MACRO25] = "Macro25", [KEY_MACRO26] = "Macro26", [KEY_MACRO27] = "Macro27",
[KEY_MACRO28] = "Macro28", [KEY_MACRO29] = "Macro29", [KEY_MACRO30] = "Macro30",
}; };
static const char *relatives[REL_MAX + 1] = { static const char *relatives[REL_MAX + 1] = {
......
...@@ -569,6 +569,16 @@ static void hidinput_update_battery(struct hid_device *dev, int value) ...@@ -569,6 +569,16 @@ static void hidinput_update_battery(struct hid_device *dev, int value)
} }
#endif /* CONFIG_HID_BATTERY_STRENGTH */ #endif /* CONFIG_HID_BATTERY_STRENGTH */
static bool hidinput_field_in_collection(struct hid_device *device, struct hid_field *field,
unsigned int type, unsigned int usage)
{
struct hid_collection *collection;
collection = &device->collection[field->usage->collection_index];
return collection->type == type && collection->usage == usage;
}
static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
struct hid_usage *usage) struct hid_usage *usage)
{ {
...@@ -634,6 +644,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel ...@@ -634,6 +644,18 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
else else
code += BTN_TRIGGER_HAPPY - 0x10; code += BTN_TRIGGER_HAPPY - 0x10;
break; break;
case HID_CP_CONSUMER_CONTROL:
if (hidinput_field_in_collection(device, field,
HID_COLLECTION_NAMED_ARRAY,
HID_CP_PROGRAMMABLEBUTTONS)) {
if (code <= 0x1d)
code += KEY_MACRO1;
else
code += BTN_TRIGGER_HAPPY - 0x1e;
} else {
goto ignore;
}
break;
default: default:
switch (field->physical) { switch (field->physical) {
case HID_GD_MOUSE: case HID_GD_MOUSE:
...@@ -1318,12 +1340,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct ...@@ -1318,12 +1340,12 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return; return;
} }
if (usage->hid == (HID_UP_DIGITIZER | 0x003c)) { /* Invert */ if (usage->hid == HID_DG_INVERT) {
*quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT); *quirks = value ? (*quirks | HID_QUIRK_INVERT) : (*quirks & ~HID_QUIRK_INVERT);
return; return;
} }
if (usage->hid == (HID_UP_DIGITIZER | 0x0032)) { /* InRange */ if (usage->hid == HID_DG_INRANGE) {
if (value) { if (value) {
input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1); input_event(input, usage->type, (*quirks & HID_QUIRK_INVERT) ? BTN_TOOL_RUBBER : usage->code, 1);
return; return;
...@@ -1333,7 +1355,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct ...@@ -1333,7 +1355,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return; return;
} }
if (usage->hid == (HID_UP_DIGITIZER | 0x0030) && (*quirks & HID_QUIRK_NOTOUCH)) { /* Pressure */ if (usage->hid == HID_DG_TIPPRESSURE && (*quirks & HID_QUIRK_NOTOUCH)) {
int a = field->logical_minimum; int a = field->logical_minimum;
int b = field->logical_maximum; int b = field->logical_maximum;
input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3)); input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
......
...@@ -130,7 +130,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i ...@@ -130,7 +130,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
if (!mouse || !input_dev) if (!mouse || !input_dev)
goto fail1; goto fail1;
mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma); mouse->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &mouse->data_dma);
if (!mouse->data) if (!mouse->data)
goto fail1; goto fail1;
......
...@@ -102,6 +102,7 @@ struct hid_item { ...@@ -102,6 +102,7 @@ struct hid_item {
#define HID_COLLECTION_PHYSICAL 0 #define HID_COLLECTION_PHYSICAL 0
#define HID_COLLECTION_APPLICATION 1 #define HID_COLLECTION_APPLICATION 1
#define HID_COLLECTION_LOGICAL 2 #define HID_COLLECTION_LOGICAL 2
#define HID_COLLECTION_NAMED_ARRAY 4
/* /*
* HID report descriptor global item tags * HID report descriptor global item tags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment