Re: ACM USB modem on Kernel 2.6.0-test

From: David Brownell
Date: Fri Oct 17 2003 - 15:06:47 EST


David Brownell wrote:

Hmm ... maybe usbcore would be better off with a less
naive algorithm for choosing defaults. Like, preferring
configurations without proprietary device protocols.
That'd solve every cdc-acm case, and likely others.

In fact, here's a patch with that very change. Does
it make current 2.6.0-test kernels work "out of the box"
again with your USB modems?

- Dave



--- 1.143/drivers/usb/core/usb.c Thu Sep 25 03:59:51 2003
+++ edited/drivers/usb/core/usb.c Fri Oct 17 12:18:16 2003
@@ -991,6 +997,7 @@
int err = -EINVAL;
int i;
int j;
+ int config;

/*
* Set the driver for the usb device to point to the "generic" driver.
@@ -1105,15 +1112,27 @@

/* choose and set the configuration. that registers the interfaces
* with the driver core, and lets usb device drivers bind to them.
+ * NOTE: should interact with hub power budgeting.
*/
+ config = dev->config[0].desc.bConfigurationValue;
if (dev->descriptor.bNumConfigurations != 1) {
+ for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
+ /* heuristic: Linux is more likely to have class
+ * drivers, so avoid vendor-specific interfaces.
+ */
+ if (dev->config[i].interface[0]->altsetting
+ ->desc.bInterfaceClass
+ == USB_CLASS_VENDOR_SPEC)
+ continue;
+ config = dev->config[i].desc.bConfigurationValue;
+ break;
+ }
dev_info(&dev->dev,
"configuration #%d chosen from %d choices\n",
- dev->config[0].desc.bConfigurationValue,
+ config,
dev->descriptor.bNumConfigurations);
}
- err = usb_set_configuration(dev,
- dev->config[0].desc.bConfigurationValue);
+ err = usb_set_configuration(dev, config);
if (err) {
dev_err(&dev->dev, "can't set config #%d, error %d\n",
dev->config[0].desc.bConfigurationValue, err);