This patch (as853) cleans up the new USB blacklist code in several ways: Replace the STRING_FETCH quirk with STRING_FETCH_255, meaning not to use a 255-byte query when retrieving string descriptors. This is all that the problem-causing HP scanners require.
Improve some comment texts. Don't log the quirks value if it is 0. Make sysfs display the quirks value in hexadecimal, which will be more informative. Signed-off-by: Alan Stern <[EMAIL PROTECTED]> --- Index: usb-2.6/drivers/usb/core/message.c =================================================================== --- usb-2.6.orig/drivers/usb/core/message.c +++ usb-2.6/drivers/usb/core/message.c @@ -686,7 +686,10 @@ static int usb_string_sub(struct usb_dev /* Try to read the string descriptor by asking for the maximum * possible number of bytes */ - rc = usb_get_string(dev, langid, index, buf, 255); + if (dev->quirks & USB_QUIRK_STRING_FETCH_255) + rc = -EIO; + else + rc = usb_get_string(dev, langid, index, buf, 255); /* If that failed try to read the descriptor length, then * ask for just that many bytes */ @@ -811,9 +814,6 @@ char *usb_cache_string(struct usb_device char *smallbuf = NULL; int len; - if (udev->quirks & USB_QUIRK_STRING_FETCH) - return NULL; - if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { if ((len = usb_string(udev, index, buf, 256)) > 0) { if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) Index: usb-2.6/drivers/usb/core/quirks.c =================================================================== --- usb-2.6.orig/drivers/usb/core/quirks.c +++ usb-2.6/drivers/usb/core/quirks.c @@ -29,23 +29,23 @@ */ static const struct usb_device_id usb_quirk_list[] = { /* HP 5300/5370C scanner */ - { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH }, - - /* Seiko Epson Corp. Perfection 1250 */ - { USB_DEVICE(0x04b8, 0x010f), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, + { USB_DEVICE(0x03f0, 0x0701), + .driver_info = USB_QUIRK_STRING_FETCH_255 }, /* Elsa MicroLink 56k (V.250) */ - { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, + { USB_DEVICE(0x05cc, 0x2267), + .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, /* USB Blackberry devices */ - { USB_DEVICE(0x0fca, 0x0001), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, + { USB_DEVICE(0x0fca, 0x0001), + .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, { } /* terminating entry must be last */ }; -static void usb_autosuspend_quirk(struct usb_device *udev) +static inline void usb_autosuspend_quirk(struct usb_device *udev) { - /* unbalanced resume that will prevent autosuspension */ + /* unbalanced resume to prevent autosuspends */ usb_autoresume_device(udev); } @@ -54,7 +54,7 @@ static const struct usb_device_id *find_ const struct usb_device_id *id = usb_quirk_list; for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || - id->driver_info; id++) { + id->driver_info; id++) { if (usb_match_device(udev, id)) return id; } @@ -71,8 +71,9 @@ void usb_detect_quirks(struct usb_device id = find_id(udev); if (id) udev->quirks = (u32)(id->driver_info); - - dev_dbg(&udev->dev, "USB quirks for this device: %x\n", udev->quirks); + if (udev->quirks) + dev_dbg(&udev->dev, "USB quirks for this device: %x\n", + udev->quirks); /* do any special quirk handling here if needed */ if (udev->quirks & USB_QUIRK_NO_AUTOSUSPEND) Index: usb-2.6/drivers/usb/core/sysfs.c =================================================================== --- usb-2.6.orig/drivers/usb/core/sysfs.c +++ usb-2.6/drivers/usb/core/sysfs.c @@ -154,7 +154,7 @@ show_quirks(struct device *dev, struct d struct usb_device *udev; udev = to_usb_device(dev); - return sprintf(buf, "%d\n", udev->quirks); + return sprintf(buf, "0x%x\n", udev->quirks); } static DEVICE_ATTR(quirks, S_IRUGO, show_quirks, NULL); Index: usb-2.6/include/linux/usb/quirks.h =================================================================== --- usb-2.6.orig/include/linux/usb/quirks.h +++ usb-2.6/include/linux/usb/quirks.h @@ -1,11 +1,11 @@ /* - * This file holds the definitions of quirks found in USB devices + * This file holds the definitions of quirks found in USB devices. * Only quirks that affect the whole device, not an interface, - * belong here + * belong here. */ -/* devices which must not be autosuspended */ +/* device must not be autosuspended */ #define USB_QUIRK_NO_AUTOSUSPEND 0x00000001 -/* devices which crash when string descriptors are fetched */ -#define USB_QUIRK_STRING_FETCH 0x00000002 +/* string descriptors must not be fetched using a 255-byte read */ +#define USB_QUIRK_STRING_FETCH_255 0x00000002 ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel