MOD_UNLOAD and driver with cdev
Kostik Belousov
kostikbel at gmail.com
Wed Jan 21 07:57:18 PST 2009
On Wed, Jan 21, 2009 at 05:50:38PM +0200, Andriy Gapon wrote:
> on 21/01/2009 17:39 Kostik Belousov said the following:
> > On Wed, Jan 21, 2009 at 05:03:20PM +0200, Andriy Gapon wrote:
> >> Do I need to code for MOD_UNLOAD for driver module that also creates a cdev?
> >> I see in the current code that one strategy is to simply call
> >> destroy_dev(). I guess detach routines are called automatically and
> >> destroy_dev can be done there as well..
> > What are the detach routines ? Do you mean newbus device detach ?
>
> Yes, device_detach. This seems to work and make_device_driver.sh also
> suggests it this way. But I am not sure about possible races.
>
> > Yes, the usual strategy is to call destroy_dev from unload handler.
> >
> >> Is it reasonable to refuse unload if cdev is in use (in MOD_QUIESCE)?
> >> How to check for that best?
> >
> > This cannot be checked race-free.
>
> So no point in trying?
I would say no. You could use count_dev(), but my own experience shown
that ability to unload driver is more important then unadvertently
knock out filedescriptor from under the running program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20090121/0573c82b/attachment.pgp
More information about the freebsd-hackers
mailing list