On Wed, Aug 26, 2020 at 11:37:50AM +0300, Mathias Nyman wrote: > On 25.8.2020 18.10, Alan Stern wrote: > > There's got to be a better way to do this, something that doesn't > > involve so much code duplication. For instance, maybe we could make > > this routine and usb_set_configuration() both call a new > > __usb_set_config(), with an extra flag telling the routine whether to > > change the interface devices and bindings. > > I agree that this needs cleaning up, this code was intended for testing. > > It allows us to call usb_hcd_alloc_bandwidth() once with a configuration > and with the old endpoint pointers still intact, leading to one configure > endpoint command for xhci with the relevant drop and add endpoint flags set, > all in one go. > > Looks like the last part usb_disable_device() does similar endpoint code > churning to flush, disable, drop, and remove endpoints. May we could start > by turning that code into some useful helper first? usb_disable_device() is _supposed_ to be the useful helper! :-) But yes, it could be split into two pieces. I still think it would be worthwhile to combine usb_set_configuration() and usb_reset_configuration() into one routine, since they have to do a lot of the same things. Alan Stern