On Wed, 2 Nov 2005, Greg KH wrote:

> > > Your only requirement is that it is outside of your local 
> > > device structure so that you can syncronize things.
> > 
> > Obviously :-) I suppose the reason why I need a semaphore and can't use a 
> > spinlock is that the call to kref_put in disconnect() must be protected by 
> > the lock, and the release() function called by kref_put might sleep. Is 
> > that 
> > right ? Is there another reason ?
> 
> Hm, I think kref_put might sleep, but I am not positive.  Try it with a
> spinlock held and see if the kernel complains (after enabling the sleep
> warning options in the DEBUG kernel options.)

kref_put itself doesn't sleep, but it might call the release routine and 
_that_ routine might sleep.

It's also generally true when opening a file or disconnecting a device, 
that you have to do several things (more than just kref_put) that might 
sleep.  Hence a semaphore is the appropriate sort of mutex.

Alan Stern



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
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