On Tue, 24 Nov 2009, Sarah Sharp wrote: > > There are several places where usbcore searches for altsetting 0. Can > > they all use a single subroutine? > > Are you talking about lines like this? > > /* Dig the endpoints for alt setting 0 out of the > * interface cache for this interface > */ > intf_cache = new_config->intf_cache[i]; > for (j = 0; j < intf_cache->num_altsetting; j++) { > if (intf_cache->altsetting[j].desc.bAlternateSetting == 0) > alt = &intf_cache->altsetting[j]; > } > if (!alt) { > printk(KERN_DEBUG "Did not find alt setting 0 for intf %d\n", i); > continue; > } > > Sure, I can put that into a subroutine. Good. > On a similar note, what if the device doesn't have an alternate interface > setting 0? What should usb_hcd_alloc_bandwidth() do when installing a new > configuration with an interface that doesn't have an alt setting 0? What > alternate interface setting will the device think it's at after it receives the > set configuration command? > > I see that usb_reset_configuration() has this note: > > /* No altsetting 0? We'll assume the first altsetting. > * We could use a GetInterface call, but if a device is > * so non-compliant that it doesn't have altsetting 0 > * then I wouldn't trust its reply anyway. > */ > if (!alt) > alt = &intf->altsetting[0]; Yes; there's a similar note in usb_set_configuration(). > If I follow that example, usb_hcd_alloc_bandwidth() should pick the first alt > setting if there is no alt setting 0 for a new configuration. That means I > need to set intf->cur_altsetting to that alt setting before > usb_reset_and_verify_device() calls usb_set_interface(). Correct. It's not likely to come up in practice -- I've never heard of a device with no altsetting 0. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html