On Wed, 2 Dec 2009, Alan Stern wrote: > On Mon, 30 Nov 2009, Sarah Sharp wrote: > > > Refactor out the code to find alternate interface settings into > > usb_find_alt_setting(). Print a debugging message and return null if the > > alt setting is not found. > > /** > > + * usb_find_alt_setting() - Given a configuration, find the alternate setting > > + * for the given interface. > > + * @config - the configuration to search (not necessarily the current config). > > + * @iface_num - interface number to search in > > + * @alt_num - alternate interface setting number to search for. > > + * > > + * Search the configuration's interface cache for the given alt setting. > > + */ > > +struct usb_host_interface *usb_find_alt_setting( > > + struct usb_host_config *config, > > + unsigned int iface_num, > > + unsigned int alt_num) > > +{ > > + struct usb_interface_cache *intf_cache; > > + int i; > > + > > + intf_cache = config->intf_cache[iface_num]; > > This is wrong. The entries in the interface_cache array are not stored > in order (more accurately, they are stored in the order of the > descriptors sent by the device, whatever that happens to be). You have > to search to find the right one. And I forgot to mention, the second search can be replaced with a call to usb_altnum_to_altsetting(). 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