Merge branch 'for-4.20/logitech-highres' into for-linus
[muen/linux.git] / drivers / hid / hid-input.c
index 6e84e7b9afcb1a85cbc746ad1d3e547881dc52d5..567c3bf64515d3599946c1d74aa79d52d9a61620 100644 (file)
@@ -758,6 +758,11 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                break;
 
        case HID_UP_DIGITIZER:
+               if ((field->application & 0xff) == 0x01) /* Digitizer */
+                       __set_bit(INPUT_PROP_POINTER, input->propbit);
+               else if ((field->application & 0xff) == 0x02) /* Pen */
+                       __set_bit(INPUT_PROP_DIRECT, input->propbit);
+
                switch (usage->hid & 0xff) {
                case 0x00: /* Undefined */
                        goto ignore;
@@ -1516,6 +1521,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,
        struct hid_input *hidinput = kzalloc(sizeof(*hidinput), GFP_KERNEL);
        struct input_dev *input_dev = input_allocate_device();
        const char *suffix = NULL;
+       size_t suffix_len, name_len;
 
        if (!hidinput || !input_dev)
                goto fail;
@@ -1559,10 +1565,15 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,
        }
 
        if (suffix) {
-               hidinput->name = kasprintf(GFP_KERNEL, "%s %s",
-                                          hid->name, suffix);
-               if (!hidinput->name)
-                       goto fail;
+               name_len = strlen(hid->name);
+               suffix_len = strlen(suffix);
+               if ((name_len < suffix_len) ||
+                   strcmp(hid->name + name_len - suffix_len, suffix)) {
+                       hidinput->name = kasprintf(GFP_KERNEL, "%s %s",
+                                                  hid->name, suffix);
+                       if (!hidinput->name)
+                               goto fail;
+               }
        }
 
        input_set_drvdata(input_dev, hid);
@@ -1582,6 +1593,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,
        input_dev->dev.parent = &hid->dev;
 
        hidinput->input = input_dev;
+       hidinput->application = application;
        list_add_tail(&hidinput->list, &hid->inputs);
 
        INIT_LIST_HEAD(&hidinput->reports);
@@ -1677,8 +1689,7 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)
        struct hid_input *hidinput;
 
        list_for_each_entry(hidinput, &hid->inputs, list) {
-               if (hidinput->report &&
-                   hidinput->report->application == report->application)
+               if (hidinput->application == report->application)
                        return hidinput;
        }
 
@@ -1815,6 +1826,7 @@ void hidinput_disconnect(struct hid_device *hid)
                        input_unregister_device(hidinput->input);
                else
                        input_free_device(hidinput->input);
+               kfree(hidinput->name);
                kfree(hidinput);
        }