]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/hid/wacom_sys.c
HID: i2c-hid: add Trekstor Primebook C11B to descriptor override
[mirror_ubuntu-bionic-kernel.git] / drivers / hid / wacom_sys.c
index ee71ad9b6cc1693e14a585848ca9ad3289f06454..a97f6ddf6e4bc9ca0343048c583e588a1ab2128b 100644 (file)
@@ -115,21 +115,26 @@ static void wacom_feature_mapping(struct hid_device *hdev,
        unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
        u8 *data;
        int ret;
-       int n;
+       u32 n;
 
        switch (equivalent_usage) {
+       case WACOM_HID_WD_TOUCH_RING_SETTING:
+               wacom->generic_has_leds = true;
+               break;
        case HID_DG_CONTACTMAX:
                /* leave touch_max as is if predefined */
                if (!features->touch_max) {
                        /* read manually */
-                       data = kzalloc(2, GFP_KERNEL);
+                       n = hid_report_len(field->report);
+                       data = hid_alloc_report_buf(field->report, GFP_KERNEL);
                        if (!data)
                                break;
                        data[0] = field->report->id;
                        ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
-                                               data, 2, WAC_CMD_RETRIES);
-                       if (ret == 2) {
-                               features->touch_max = data[1];
+                                              data, n, WAC_CMD_RETRIES);
+                       if (ret == n) {
+                               ret = hid_report_raw_event(hdev,
+                                       HID_FEATURE_REPORT, data, n, 0);
                        } else {
                                features->touch_max = 16;
                                hid_warn(hdev, "wacom_feature_mapping: "
@@ -291,6 +296,14 @@ static void wacom_usage_mapping(struct hid_device *hdev,
                }
        }
 
+       /* 2nd-generation Intuos Pro Large has incorrect Y maximum */
+       if (hdev->vendor == USB_VENDOR_ID_WACOM &&
+           hdev->product == 0x0358 &&
+           WACOM_PEN_FIELD(field) &&
+           wacom_equivalent_usage(usage->hid) == HID_GD_Y) {
+               field->logical_maximum = 43200;
+       }
+
        switch (usage->hid) {
        case HID_GD_X:
                features->x_max = field->logical_maximum;
@@ -415,7 +428,7 @@ static int wacom_set_device_mode(struct hid_device *hdev,
        u8 *rep_data;
        struct hid_report *r;
        struct hid_report_enum *re;
-       int length;
+       u32 length;
        int error = -ENOMEM, limit = 0;
 
        if (wacom_wac->mode_report < 0)
@@ -1109,8 +1122,10 @@ static int __wacom_devm_sysfs_create_group(struct wacom *wacom,
        devres->root = root;
 
        error = sysfs_create_group(devres->root, group);
-       if (error)
+       if (error) {
+               devres_free(devres);
                return error;
+       }
 
        devres_add(&wacom->hdev->dev, devres);
 
@@ -2347,23 +2362,23 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index)
        int i;
        unsigned long flags;
 
-       spin_lock_irqsave(&remote->remote_lock, flags);
-       remote->remotes[index].registered = false;
-       spin_unlock_irqrestore(&remote->remote_lock, flags);
+       for (i = 0; i < WACOM_MAX_REMOTES; i++) {
+               if (remote->remotes[i].serial == serial) {
 
-       if (remote->remotes[index].battery.battery)
-               devres_release_group(&wacom->hdev->dev,
-                                    &remote->remotes[index].battery.bat_desc);
+                       spin_lock_irqsave(&remote->remote_lock, flags);
+                       remote->remotes[i].registered = false;
+                       spin_unlock_irqrestore(&remote->remote_lock, flags);
 
-       if (remote->remotes[index].group.name)
-               devres_release_group(&wacom->hdev->dev,
-                                    &remote->remotes[index]);
+                       if (remote->remotes[i].battery.battery)
+                               devres_release_group(&wacom->hdev->dev,
+                                                    &remote->remotes[i].battery.bat_desc);
+
+                       if (remote->remotes[i].group.name)
+                               devres_release_group(&wacom->hdev->dev,
+                                                    &remote->remotes[i]);
 
-       for (i = 0; i < WACOM_MAX_REMOTES; i++) {
-               if (remote->remotes[i].serial == serial) {
                        remote->remotes[i].serial = 0;
                        remote->remotes[i].group.name = NULL;
-                       remote->remotes[i].registered = false;
                        remote->remotes[i].battery.battery = NULL;
                        wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN;
                }