On Sun, Feb 23, 2003, David Brownell <[EMAIL PROTECTED]> wrote:
> 
> >>Why should drivers use usb_get_dev in probe, and usb_put_dev in disconnect?
> > 
> > 
> > No reason. A reference is already done by the core which covers the
> > reference for that whole period of time.
> 
> A reference which is no longer valid after disconnect() ...

Yes, but that's completely different.

The comment suggests getting a reference in probe() and then putting it
in disconnect().

But that's completely superfluous since the core does that already in
usb_new_device() (before all probe() calls) and usb_disconnect() (after
all disconnect() calls).

The only time a driver would need to get a reference is if it intends to
use the device structure past the disconnect() callback.

It wouldn't hurt to follow the directions in the comment, but it
wouldn't help either.

Which is ironically, not necessary if using your version of the contract.

> Hmm, that sounds like that other thread... a driver using
> that implicit reference after disconnect() returned would
> clearly have a refcount bug!

That is correct.

> > If you want to use the device structure longer than that, you need to
> > keep a reference yourself.
> > 
> > It seems like another misunderstading.
> 
> But you're not saying that kind of usage would be incorrect,
> so I don't see what would have been mis-understood.

It's superfluous, so why should a driver "normally" do that? They
shouldn't.

> Only that more interesting examples -- like Greg's "urb
> completes after disconnect() returns" -- might also be
> added to that documentation.
> 
> Of course, if that's done, then probe/disconnect text
> could stand to be clarified:  saying when refcounting
> for devices is implicitly being done.

Yes, the comment should be changed to remove the the text in question
and add something about when an implicit reference is done.

JE



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to