From 1322dbad5ff6e85d6da07bac7c772c2457c0a8aa Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 29 Mar 2010 12:03:17 +0200 Subject: [PATCH] --- yaml --- r: 195335 b: refs/heads/master c: 317149c655defedfaf432143b86a720cfc12a424 h: refs/heads/master i: 195333: a6042b6ad16c47c71c2b4c93891d78369bde0e55 195331: 9dea06f36117b281404d21f05d29ab37259de793 195327: 184b6469b15d6ca747b06b803f2d9bef1d0d2602 v: v3 --- [refs] | 2 +- trunk/drivers/usb/core/config.c | 16 ++++++++++++++-- trunk/drivers/usb/core/quirks.c | 4 ++++ trunk/include/linux/usb/quirks.h | 4 ++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index a9317377ad4d..f701560ed7aa 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7f0ae3a8eeb7f231dc99cee7c871ba64e07ebefe +refs/heads/master: 317149c655defedfaf432143b86a720cfc12a424 diff --git a/trunk/drivers/usb/core/config.c b/trunk/drivers/usb/core/config.c index 77e0dda3a2fb..16c1157be3fc 100644 --- a/trunk/drivers/usb/core/config.c +++ b/trunk/drivers/usb/core/config.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -479,9 +480,10 @@ static int usb_parse_interface(struct device *ddev, int cfgno, return buffer - buffer0 + i; } -static int usb_parse_configuration(struct device *ddev, int cfgidx, +static int usb_parse_configuration(struct usb_device *dev, int cfgidx, struct usb_host_config *config, unsigned char *buffer, int size) { + struct device *ddev = &dev->dev; unsigned char *buffer0 = buffer; int cfgno; int nintf, nintf_orig; @@ -550,6 +552,16 @@ static int usb_parse_configuration(struct device *ddev, int cfgidx, } inum = d->bInterfaceNumber; + + if ((dev->quirks & USB_QUIRK_HONOR_BNUMINTERFACES) && + n >= nintf_orig) { + dev_warn(ddev, "config %d has more interface " + "descriptors, than it declares in " + "bNumInterfaces, ignoring interface " + "number: %d\n", cfgno, inum); + continue; + } + if (inum >= nintf_orig) dev_warn(ddev, "config %d has an invalid " "interface number: %d but max is %d\n", @@ -801,7 +813,7 @@ int usb_get_configuration(struct usb_device *dev) dev->rawdescriptors[cfgno] = bigbuffer; - result = usb_parse_configuration(&dev->dev, cfgno, + result = usb_parse_configuration(dev, cfgno, &dev->config[cfgno], bigbuffer, length); if (result < 0) { ++cfgno; diff --git a/trunk/drivers/usb/core/quirks.c b/trunk/drivers/usb/core/quirks.c index f073c5cb4e7b..f22d03df8b17 100644 --- a/trunk/drivers/usb/core/quirks.c +++ b/trunk/drivers/usb/core/quirks.c @@ -71,6 +71,10 @@ static const struct usb_device_id usb_quirk_list[] = { /* SKYMEDI USB_DRIVE */ { USB_DEVICE(0x1516, 0x8628), .driver_info = USB_QUIRK_RESET_RESUME }, + /* BUILDWIN Photo Frame */ + { USB_DEVICE(0x1908, 0x1315), .driver_info = + USB_QUIRK_HONOR_BNUMINTERFACES }, + /* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, diff --git a/trunk/include/linux/usb/quirks.h b/trunk/include/linux/usb/quirks.h index 0a555dd131fc..16b7f3347545 100644 --- a/trunk/include/linux/usb/quirks.h +++ b/trunk/include/linux/usb/quirks.h @@ -22,4 +22,8 @@ /*device will morph if reset, don't use reset for handling errors */ #define USB_QUIRK_RESET_MORPHS 0x00000010 +/* device has more interface descriptions than the bNumInterfaces count, + and can't handle talking to these interfaces */ +#define USB_QUIRK_HONOR_BNUMINTERFACES 0x00000020 + #endif /* __LINUX_USB_QUIRKS_H */