USB: accept some invalid ep0-maxpacket values
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 14 Oct 2010 19:25:21 +0000 (15:25 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 22 Oct 2010 17:22:14 +0000 (10:22 -0700)
A few devices (such as the RCA VR5220 voice recorder) are so
non-compliant with the USB spec that they have invalid maxpacket sizes
for endpoint 0.  Nevertheless, as long as we can safely use them, we
may as well do so.

This patch (as1432) softens our acceptance criterion by allowing
high-speed devices to have ep0-maxpacket sizes other than 64.  A
warning is printed in the system log when this happens, and the
existing error message is clarified.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: James <bjlockie@lockie.ca>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hub.c

index 7f82c48..27115b4 100644 (file)
@@ -2861,13 +2861,16 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
        else
                i = udev->descriptor.bMaxPacketSize0;
        if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
-               if (udev->speed != USB_SPEED_FULL ||
+               if (udev->speed == USB_SPEED_LOW ||
                                !(i == 8 || i == 16 || i == 32 || i == 64)) {
-                       dev_err(&udev->dev, "ep0 maxpacket = %d\n", i);
+                       dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
                        retval = -EMSGSIZE;
                        goto fail;
                }
-               dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
+               if (udev->speed == USB_SPEED_FULL)
+                       dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
+               else
+                       dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i);
                udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
                usb_ep0_reinit(udev);
        }