On Tue, 22 Jul 2003, David Brownell wrote:

> I think the name "usb_unbind_interface" is clearest about
> the responsibility of that routine.

Sounds good.

> > The other half of the problem comes after the driver has been
> > disconnected.  The endpoints will remain disabled, so the next driver that
> > tries to bind the interface is out of luck!  I added enable_interface(),
> > which undoes the effects of disable_interface().
> 
> I'd rather see this done a bit differently.  One issue being
> device state, lingering between drivers.  We normally guarantee
> that it's been reset before drivers get bound ... but when you
> do it this way, you prevent that.  The device could be in the
> middle of some operation, waiting for the driver to do something.
> 
> A cleaner solution would be calling usb_set_interface() to restore
> the default altsetting, instead of nuke_urbs().  And remove that
> special logic now found in usb_set_interface(), for the "there's
> only one altsetting" case ... if the actual SET_INTERFACE gives a
> protocol stall, just clear each endpoint's halt status manually.
> 
> That solution would address several problems at once:
> 
>   - Kill the (correct) urbs on driver rmmod, the way that one
>     bit of new code should have been working;
> 
>   - Fix the bugs folk have reported where that special logic
>     makes some correctly-functioning devices misbhehave, since
>     it won't reset the endpoints implicitly via SET_INTERFACE
>     unless there's more than one altsetting (and reports success,
>     as if it did);
> 
>   - Fix the problem some folk have with that logic for conformant
>     devices that don't handle SET_INTERFACE, but could achieve
>     the right result by clearing each endpoint's HALT status;
> 
>   - Make sure the next driver bound to that interface always
>     has a clean slate, with no half-completed operations that
>     it'd need to abort or recover from.
> 
> So while this is a good bug to fix, I don't really like this
> particular fix because of those related issues.

I gather then that you would like to keep disable_interface() but not 
enable_interface().  Instead, after unbinding the driver 
usb_unbind_interface() should call usb_set_interface() to restore 
altsetting 0.  Obviously that shouldn't be done _before_ unbinding the 
driver.

Finally, usb_set_interface() needs to be modified to remove the
special-case logic for interfaces with only 1 altsetting.  If the
SET_INTERFACE control request stalls, the function should manually clear
the HALT feature for each endpoint in the new altsetting.  I guess it
wouldn't hurt to include endpoint 0 as well.

usb_set_interface() does have the disadvantage of duplicating the work
done by disable_interface() -- does that really have to be in there?

Alan Stern



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to