On Mon, May 13, 2002 at 11:31:17AM -0400, Johannes Erdfelt wrote:
> On Mon, May 13, 2002, Greg KH <[EMAIL PROTECTED]> wrote:
> > Here's a follow up patch to be applied on top of your previous patch.
> > 
> > Much of the confusion for me (and probably others) was the fact that we
> > had to modify reference counts of devices and then free them up when we
> > were finished with them.  Why make the driver authors have to figure out
> > the count logic (i.e. when to call usb_free_dev()) when we were already
> > using reference counts?
> 
> Hmm, that's how it was with my patch.

Sorry if I implied this, but I was trying to describe the way David's
patch was implemented, not yours.

> > Now when the last person calls usb_put_dev() or usb_free_dev() the
> > structure is cleaned up.  This allows the different host controller
> > drivers to implement their logic differently if they want to (as they
> > do), and everyone can be happy and stop arguing about the "proper" way
> > to write their host controller drivers :)
> 
> Do you mean that HCD's can cleanup after buggy device drivers?
> 
> I don't think anyone was arguing how the proper way to their write their
> host controller driver is, but rather what the proper coding convention
> is in the kernel.

Oh, that's easily settled.  To quote Documentation/CodingStyle, chapter
8:
        Remember: if another thread can find your data structure, and
        you don't have a reference count on it, you almost certainly
        have a bug.

The combination of these two patches now solves that bug.

<shameless_plug>
For more description of "proper" kernel coding style, I have a paper and
presentation at OLS this year:
http://www.linuxsymposium.org/2002/view_txt.php?text=abstract&talk=57
</shameless_plug>

> > One question remains, should device drivers call usb_get_dev() like some
> > currently do (storage, some network, and the usbvideo core)?  Does this
> > protect something from happening that I don't see?  And if all drivers
> > should call it, shouldn't a successful return from probe() back to the
> > usb core do the call for the driver?
> 
> It most certainly couldn't hurt. However, I don't think it's necessary
> since the core already does one increment, when the device is created.
> It then does one decrement after it calls the disconnect for all of the
> interfaces.

Ok, thanks for clarifying this.

> If they do anything after disconnect, they should use reference counts.
> If they don't, it's not necessary.

I thought so.  So we can get rid of those comments in cdc-ether.c now :)

thanks,

greg k-h

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to