On Sat, Feb 22, 2003, Greg KH <[EMAIL PROTECTED]> wrote: > On Sun, Feb 23, 2003 at 12:36:02AM +0100, Duncan Sands wrote: > > > The philosophy is often called "programming by contract". > > > > > > And the contract is: usbcore agrees to work with your driver > > > and do everything right, if your driver agrees to do a few > > > specific things. One of those specific things is never using > > > the device after you return from disconnect(), either directly > > > (as you're doing here) or indirectly (urb still pending, say). > > > > > > If you break such programming contracts, bad things happen; > > > that's part of why the contract exists. There are lots of > > > components interacting, relying on contracts to be followed, > > > and if they aren't ... it's impractical to guarantee that > > > all the failure modes will always be benign. > > > > Pity this contract is undocumented. > > And flat wrong. > > For 2.5, your driver can use the struct usb_device for as long as it > wants to, provided it got a reference to it in the first place with > usb_get_dev(). It makes driver writing a hell of a lot easer, just take > a look at all of the nasty lock mess I took out of the usb-serial core > because of this. > > For 2.4, I want to backport these changes to the core to also ensure > that "this contract" is not needed. But I haven't had the time to do so > yet. Again, patches gleefully accepted :)
The intent was for 2.4 to have this same contract. Having a reference count on the device structure is pointless if that weren't the case. However, there may be bugs there in HCDs, the core, or drivers with respect to this because it was never clearly defined or enforced. uhci.c was designed with this contract in mind and much of the core was too. There are still some bugs that I've found that I'm testing patches for now. JE ------------------------------------------------------- This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
