On Tue, 26 Apr 2005, Roman Kagan wrote:

> On Mon, Apr 25, 2005 at 04:01:07PM -0400, Alan Stern wrote:
> > I think usb_driver_claim_interface is correct as it stands.  It was a 
> > mistake to leave out from usb_driver_release_interface originally the line 
> > setting iface->condition to USB_INTERFACE_UNBINDING.
> 
> But it would be asymmetric then.

In what sense?  You mean because we don't also protect against a driver
calling usb_driver_claim_interface from within that interface's probe?  
We don't need to check for that, do we?

>  FWIW my personal preference would be
> to get rid of usb_interface.condition altogether, and always use the
> driver base facilities to deduce the current interface bound state.
> Otherwise maintaining a private field in sync with what the driver base
> thinks is always error prone.

There are other reasons for keeping usb_interface.condition.  For one 
thing, the driver-model data doesn't tell when a bind or unbind is in 
progress.  That information is used elsewhere in usbcore.


> > The _driver_ shouldn't check.  The check should be part of the
> > driver-model core in __driver_attach, at the place where it checks whether
> > the device is already bound to a driver.  In fact, this check can subsume
> > that one, since the klist_node will always be attached whenever the device 
> > is bound.
> 
> Indeed.  I guess all checks for whether the device is associated with
> a driver ought to be changed from !dev->driver to
> klist_node_attached(&dev->knode_driver).

I'm not so sure about that.  You wouldn't want to dereference dev->driver 
after doing only the klist_node_attached check!

Unfortunately there are several spots where a device can be bound to a
driver, and the code generally doesn't check for errors.  This makes it
difficult to check klist_node_attached at each spot.  The best solution
would be always to have device_release_driver wait for the klist_node's
completion before releasing the semaphore.  But there's no simple way to
do that, given how driver_detach works.

Alan Stern



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to