Re: [RFC/PATCH] usb: gadget: composite: don't call f->set_alt() from USB_REQ_SET_CONFIGURATION

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

 



On Thu, 16 Aug 2012, Sebastian Andrzej Siewior wrote:

> * Felipe Balbi | 2012-08-16 09:30:05 [+0300]:
> 
> >I couldn't find anywhere in the USB Specification
> >where it requires us to make sure all interfaces start
> >on Alternate Setting zero. IMHO, we should consider
> >initial state as UNKNOWN and not rely on that being
> >zero or anything.
> 
> Table 9-1 in USB2.0 spec says once a device is configured (after
> USB_REQ_SET_CONFIGURATION) is may use its functions. So the default
> function should be activated.
> 
> 9.6.5 says:
> |An interface may include alternate settings that allow the endpoints
> |and/or their characteristics to be varied after the device has been
> |configured. The default setting for an interface is always alternate
> |setting zero.
> |The SetInterface() request is used to select an alternate setting or to
> |return to the default setting.
> 
> That means we have to start at zero. The host may change it, it may not
> use SetInterface() at all if the default setting is fine.
> 
> 9.1.1.5 says:
> |Configuring a device or changing an alternate setting causes all of the status
> |and configuration values associated with endpoints in the affected
> |interfaces to be set to their default values.
> 
> I think we can skip ->set_alt() if the old setting is the same as the
> new one.

No, you can't.  Even if the two altsettings are the same, the gadget
has to reset its state.  This means clearing the fifos and data toggles
for all the endpoints in the interface, and can include arbitrarily
large amounts of other state.

On the other hand, it might make sense to avoid calling the set_alt
method when changing configs.  Function drivers should be smart enough
to automatically install altsetting 0 for each interface when the
config changes; they shouldn't need to be told to install it again.

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


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

  Powered by Linux