The 'wacom_update_name' function is responsible for producing names for
the input device nodes based on the hardware device name. Commit f2209d4
added the ability to strip off prefixes like "Wacom Co.,Ltd." where the
prefix was immediately (and redundantly) followed by "Wacom". The
2nd-generation Intuos Pro 2 has such a prefix, but with a small error
(the period and comma are swapped) that prevents the existing code from
matching it. We're loath to extend the number of cases out endlessly and
so instead try to be smarter about name generation.

We observe that the cause of the redundant prefixes is HID combining the
manufacturer and product strings of USB devices together. By using the
original product name (with "Wacom" prefixed, if it does not already
exist in the string) we can bypass the gyrations to find and remove
redundant prefixes. Other devices either don't have a manufacturer string
that needs to be removed (Bluetooth, uhid) or should have their name
generated from scratch (I2C).

Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
Acked-By: Benjamin Tissoires <benjamin.tissoi...@redhat.com>
Signed-off-by: Jiri Kosina <jkos...@suse.cz>
[jason.gere...@wacom.com: Imported into input-wacom repository (09dc28acae)]
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
[jason.gere...@wacom.com: Backported from input-wacom repository (bb55947)]
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 2.6.30/wacom_wac.c |  8 +++---
 2.6.36/wacom_wac.c |  8 +++---
 2.6.38/wacom_wac.c |  8 +++---
 3.17/wacom_sys.c   | 78 ++++++++++++++++++++++++++++++++----------------------
 3.7/wacom_wac.c    |  8 +++---
 5 files changed, 63 insertions(+), 47 deletions(-)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index f12f810..cab65cf 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -2561,14 +2561,14 @@ static const struct wacom_features wacom_features_0x354 
=
        { "Wacom Cintiq Pro 16UHD Touch", WACOM_PKGLEN_MSPROT, .type = 
WACOM_MSPROT,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x350 }; /* Touch */
 static const struct wacom_features wacom_features_0x357 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 
29600, 8191, 63, INTUOSP2, 9 };
+       { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 29600, 8191, 63, 
INTUOSP2, 9 };
 static const struct wacom_features wacom_features_0x358 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 
43200, 8191, 63, INTUOSP2, 9 };
+       { "Wacom Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 43200, 
8191, 63, INTUOSP2, 9 };
 static const struct wacom_features wacom_features_0x35A =
-       { "Wacom Co.,Ltd. DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
+       { "Wacom DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
          0, DTH1152, .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x368 };
 static const struct wacom_features wacom_features_0x368 =
-       { "Wacom Co.,Ltd. DTH-1152 Touch", WACOM_PKGLEN_27QHDT, .type = 
DTH1152T,
+       { "Wacom DTH-1152 Touch", WACOM_PKGLEN_27QHDT, .type = DTH1152T,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x35a }; /* Touch */
 
 #define USB_DEVICE_WACOM(prod)                                 \
diff --git a/2.6.36/wacom_wac.c b/2.6.36/wacom_wac.c
index a38dc75..4d5fc70 100644
--- a/2.6.36/wacom_wac.c
+++ b/2.6.36/wacom_wac.c
@@ -2394,16 +2394,16 @@ static const struct wacom_features wacom_features_0x353 
=
 static const struct wacom_features wacom_features_0x354 =
        { "Wacom Cintiq Pro 16UHD Touch", WACOM_PKGLEN_MSPROT, .type = 
WACOM_MSPROT }; /* Touch */
 static const struct wacom_features wacom_features_0x357 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 
29600, 8191,
+       { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 29600, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x358 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 
43200, 8191,
+       { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 43200, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x35A =
-       { "Wacom Co.,Ltd. DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
+       { "Wacom DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
          0, DTH1152, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x368 =
-       { "Wacom Co.,Ltd. DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
+       { "Wacom DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
          .type = DTH1152T }; /* Touch */
 static const struct wacom_features wacom_features_0x6004 =
        { "ISD-V4",               WACOM_PKGLEN_GRAPHIRE,  12800,  8000,  255,
diff --git a/2.6.38/wacom_wac.c b/2.6.38/wacom_wac.c
index 79c50fb..cf94c0f 100644
--- a/2.6.38/wacom_wac.c
+++ b/2.6.38/wacom_wac.c
@@ -3244,17 +3244,17 @@ static const struct wacom_features wacom_features_0x354 
=
        { "Wacom Cintiq Pro 16UHD Touch", WACOM_PKGLEN_MSPROT, .type = 
WACOM_MSPROT,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x350 }; /* Touch */
 static const struct wacom_features wacom_features_0x357 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 
29600, 8191,
+       { "Wacom Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 29600, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 
10 };
 static const struct wacom_features wacom_features_0x358 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 
43200, 8191,
+       { "Wacom Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 43200, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 
10 };
 static const struct wacom_features wacom_features_0x35A =
-       { "Wacom Co.,Ltd. DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
+       { "Wacom DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
          0, DTH1152, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x368 };
 static const struct wacom_features wacom_features_0x368 =
-       { "Wacom Co.,Ltd. DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
+       { "Wacom DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
          .type = DTH1152T, .touch_max = 10, .oVid = USB_VENDOR_ID_WACOM,
          .oPid = 0x35A }; /* Touch */
 
diff --git a/3.17/wacom_sys.c b/3.17/wacom_sys.c
index a1887de..9fccf59 100644
--- a/3.17/wacom_sys.c
+++ b/3.17/wacom_sys.c
@@ -22,6 +22,26 @@
 #define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
 #define DEV_ATTR_RO_PERM (S_IRUSR | S_IRGRP)
 
+static int __wacom_is_usb_parent(struct usb_device *usbdev, void *ptr)
+{
+       struct hid_device *hdev = ptr;
+       struct device *parent = hdev->dev.parent;
+       struct usb_host_config *config = usbdev->actconfig;
+       int i;
+
+       for (i = 0; i < config->desc.bNumInterfaces; i++) {
+               if (&config->interface[i]->dev == parent)
+                       return 1;
+       }
+       return 0;
+}
+
+static bool wacom_is_using_usb_driver(struct hid_device *hdev)
+{
+       return hdev->bus == BUS_USB &&
+              usb_for_each_dev(hdev, __wacom_is_usb_parent);
+}
+
 static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
                            size_t size, unsigned int retries)
 {
@@ -1855,41 +1875,37 @@ static void wacom_update_name(struct wacom *wacom, 
const char *suffix)
 
        /* Generic devices name unspecified */
        if ((features->type == HID_GENERIC) && !strcmp("Wacom HID", 
features->name)) {
-               if (strstr(wacom->hdev->name, "Wacom") ||
-                   strstr(wacom->hdev->name, "wacom") ||
-                   strstr(wacom->hdev->name, "WACOM")) {
-                       /* name is in HID descriptor, use it */
-                       strlcpy(name, wacom->hdev->name, sizeof(name));
-
-                       /* strip out excess whitespaces */
-                       while (1) {
-                               char *gap = strstr(name, "  ");
-                               if (gap == NULL)
-                                       break;
-                               /* shift everything including the terminator */
-                               memmove(gap, gap+1, strlen(gap));
-                       }
+               char *product_name = wacom->hdev->name;
 
-                       /* strip off excessive prefixing */
-                       if (strstr(name, "Wacom Co.,Ltd. Wacom ") == name) {
-                               int n = strlen(name);
-                               int x = strlen("Wacom Co.,Ltd. ");
-                               memmove(name, name+x, n-x+1);
-                       }
-                       if (strstr(name, "Wacom Co., Ltd. Wacom ") == name) {
-                               int n = strlen(name);
-                               int x = strlen("Wacom Co., Ltd. ");
-                               memmove(name, name+x, n-x+1);
-                       }
+               if (wacom_is_using_usb_driver(wacom->hdev)) {
+                       struct usb_interface *intf = 
to_usb_interface(wacom->hdev->dev.parent);
+                       struct usb_device *dev = interface_to_usbdev(intf);
+                       product_name = dev->product;
+               }
 
-                       /* get rid of trailing whitespace */
-                       if (name[strlen(name)-1] == ' ')
-                               name[strlen(name)-1] = '\0';
+               if (wacom->hdev->bus == BUS_I2C) {
+                       snprintf(name, sizeof(name), "%s %X",
+                                features->name, wacom->hdev->product);
+               } else if (strstr(product_name, "Wacom") ||
+                          strstr(product_name, "wacom") ||
+                          strstr(product_name, "WACOM")) {
+                       strlcpy(name, product_name, sizeof(name));
                } else {
-                       /* no meaningful name retrieved. use product ID */
-                       snprintf(name, sizeof(name),
-                                "%s %X", features->name, wacom->hdev->product);
+                       snprintf(name, sizeof(name), "Wacom %s", product_name);
                }
+
+               /* strip out excess whitespaces */
+               while (1) {
+                       char *gap = strstr(name, "  ");
+                       if (gap == NULL)
+                               break;
+                       /* shift everything including the terminator */
+                       memmove(gap, gap+1, strlen(gap));
+               }
+
+               /* get rid of trailing whitespace */
+               if (name[strlen(name)-1] == ' ')
+                       name[strlen(name)-1] = '\0';
        } else {
                strlcpy(name, features->name, sizeof(name));
        }
diff --git a/3.7/wacom_wac.c b/3.7/wacom_wac.c
index 34b2369..18b3342 100644
--- a/3.7/wacom_wac.c
+++ b/3.7/wacom_wac.c
@@ -3183,17 +3183,17 @@ static const struct wacom_features wacom_features_0x354 
=
        { "Wacom Cintiq Pro 16UHD Touch", WACOM_PKGLEN_MSPROT, .type = 
WACOM_MSPROT,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x350 }; /* Touch */
 static const struct wacom_features wacom_features_0x357 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 
29600, 8191,
+       { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOSP2, 44800, 29600, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 
10 };
 static const struct wacom_features wacom_features_0x358 =
-       { "Wacom Co,.Ltd. Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 
43200, 8191,
+       { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOSP2, 62200, 43200, 8191,
          63, INTUOSP2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 
10 };
 static const struct wacom_features wacom_features_0x35A =
-       { "Wacom Co.,Ltd. DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
+       { "Wacom DTH-1152", WACOM_PKGLEN_DTH1152, 22320, 12555, 1024,
          0, DTH1152, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x368 };
 static const struct wacom_features wacom_features_0x368 =
-       { "Wacom Co.,Ltd. DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
+       { "Wacom DTH-1152 Touch", WACOM_PKGLEN_27QHDT,
          .type = DTH1152T, .touch_max = 10, .oVid = USB_VENDOR_ID_WACOM,
          .oPid = 0x35A }; /* Touch */
 
-- 
2.13.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to