[BUG?] hid-core.c: hid->name = dev->manufacturer + dev->product ... why not + dev->serial?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

just recently I purchased two data acquisition HID devices that pretend to be
joysticks[1], because that way no special kernel drivers are required, and
because they are usually used for joystick-like purposes. The devices identify
themselves as

  idVendor           0x16c0
  idProduct          0x05ba 
  iManufacturer      1 Leo Bodnar
  iProduct           2 BU0836A Interface
  iSerial            3 A10123

The Linux kernel creates the HID/"joystick name" from only iManufacturer and
iProduct, ignoring iSerial. That way, JSIOCGNAME returns the same string
for all such devices, making an actual identification impossible.
joystick-api.txt says about JSIOCGNAME:

  #define JSIOCGNAME(len) /* get identifier string        char    */
  ...
  JSIOCGNAME(len) allows you to get the name string of the joystick

But this isn't actually true. "Leo Bodnar BU0836A Interface" is only
the name of the product, but not of the actual (joystick or whatever)
device. If you have more of these devices on the bus, then software has
no way to know which is which -- which is the one with the temperature
sensor on axis 0 etc. (Apart from doing all the USB querying itself,
of course.)

The patch below fixed the problem for me. But, certainly, the current
(mis)behaviour wasn't an accident, but intentional. But what was the
intention? What happens if I attach two actual identical joysticks?
What's the purpose of them having the same name on the system under
/dev/input/{js,event}? Not even two (human) identical twins have the
same first name, and for a reason!

I'm aware that at the moment, some software could rely on the fact
that a joystick name is just a generic product name, but that would
be easy to fix. I'm only aware of one such application, but exactly
in this case the serial number in the joystick name would actually
be an improvement!

m.




[1] http://www.leobodnar.com/products/BU0836A/





--- a/drivers/hid/usbhid/hid-core.c     2010-03-04 02:49:38.676850618 +0100
+++ b/drivers/hid/usbhid/hid-core.c     2010-03-04 03:03:43.269006052 +0100
@@ -1131,6 +1131,12 @@
                strlcat(hid->name, dev->product, sizeof(hid->name));
        }
 
+       if (dev->serial) {
+               if (hid->name[0])
+                       strlcat(hid->name, " ", sizeof(hid->name));
+               strlcat(hid->name, dev->serial, sizeof(hid->name));
+       }
+
        if (!strlen(hid->name))
                snprintf(hid->name, sizeof(hid->name), "HID %04x:%04x",
                         le16_to_cpu(dev->descriptor.idVendor),
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux