USB: iowarrior: fix up report size handling for some devices
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Jul 2020 09:49:39 +0000 (11:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jul 2020 11:19:58 +0000 (13:19 +0200)
In previous patches that added support for new iowarrior devices, the
handling of the report size was not done correct.

Fix that up and update the copyright date for the driver

Reworked from an original patch written by Christoph Jung.

Fixes: bab5417f5f01 ("USB: misc: iowarrior: add support for the 100 device")
Fixes: 5f6f8da2d7b5 ("USB: misc: iowarrior: add support for the 28 and 28L devices")
Fixes: 461d8deb26a7 ("USB: misc: iowarrior: add support for 2 OEMed devices")
Cc: stable <stable@kernel.org>
Reported-by: Christoph Jung <jung@codemercs.com>
Link: https://lore.kernel.org/r/20200726094939.1268978-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/iowarrior.c

index 4afd1ace3d32cea276e4e9ff7b5f9ac35672bc78..70ec296815268cd2d8e9f984fc93727fd454a3fb 100644 (file)
@@ -2,8 +2,9 @@
 /*
  *  Native support for the I/O-Warrior USB devices
  *
- *  Copyright (c) 2003-2005  Code Mercenaries GmbH
- *  written by Christian Lucht <lucht@codemercs.com>
+ *  Copyright (c) 2003-2005, 2020  Code Mercenaries GmbH
+ *  written by Christian Lucht <lucht@codemercs.com> and
+ *  Christoph Jung <jung@codemercs.com>
  *
  *  based on
 
@@ -802,14 +803,28 @@ static int iowarrior_probe(struct usb_interface *interface,
 
        /* we have to check the report_size often, so remember it in the endianness suitable for our machine */
        dev->report_size = usb_endpoint_maxp(dev->int_in_endpoint);
-       if ((dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) &&
-           ((dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56) ||
-            (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW56AM) ||
-            (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW28) ||
-            (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW28L) ||
-            (dev->product_id == USB_DEVICE_ID_CODEMERCS_IOW100)))
-               /* IOWarrior56 has wMaxPacketSize different from report size */
-               dev->report_size = 7;
+
+       /*
+        * Some devices need the report size to be different than the
+        * endpoint size.
+        */
+       if (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) {
+               switch (dev->product_id) {
+               case USB_DEVICE_ID_CODEMERCS_IOW56:
+               case USB_DEVICE_ID_CODEMERCS_IOW56AM:
+                       dev->report_size = 7;
+                       break;
+
+               case USB_DEVICE_ID_CODEMERCS_IOW28:
+               case USB_DEVICE_ID_CODEMERCS_IOW28L:
+                       dev->report_size = 4;
+                       break;
+
+               case USB_DEVICE_ID_CODEMERCS_IOW100:
+                       dev->report_size = 13;
+                       break;
+               }
+       }
 
        /* create the urb and buffer for reading */
        dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);