Re: [RFC v2 3/3] USB: Check bandwidth when switching alt settings.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 24, 2009 at 10:19:41AM -0500, Alan Stern wrote:
> There appears to be a problem in usb_reset_and_verify_device(), where
> the old altsettings are restored.  Initially you restore the old
> config, which allocates bandwidth for altsetting 0.  Then the routine
> calls usb_set_interface() to restore the old altsetting.  But the
> cur_alt argument passed to usb_hcd_alloc_bandwidth() will be the old
> altsetting, not altsetting 0.  To fix this, you'll have to set
> intf->cur_altsetting to point to altsetting 0 before
> usb_reset_and_verify_device() calls usb_set_interface().

Ok, I'll fix that.

> 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.


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];

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().

Sarah Sharp
--
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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux