Subject: Re: dev/audiobell.c proposal
To: Lennart Augustsson <lennart@augustsson.net>
From: Quentin Garnier <netbsd@quatriemek.com>
List: tech-kern
Date: 01/15/2004 22:17:25
Le Mon, 12 Jan 2004 00:06:58 +0100
Lennart Augustsson a ecrit :
> Perry E. Metzger wrote:
> > Sure, but why not just always do that and have the device multiple
> > open?
> 
> The current device driver arch. makes it very difficult to write
> drivers that support multiple opens.  The problem is that the device
> open routine as called on every opne, but close is only called on the
> last close.  So trying to do book keeping on what's in use is hard.

FreeBSD has a flag in the devsw structure to allow the close function to
be called at each close call on the device.

Couldn't we do that, too, either adding a field at the end of struct
{c,b}devsw or using a special value for d_type?

Then, there is very little code to change to implement the
close-on-each-call functionality.  I've just realized this is most likely
why I get such instability with the NVidia video drivers: it g/c some
memory allocations when close() is called, but of course with our
semantics it never gets to the device on NetBSD.

I'll try this and then lobby for such an option, since it obviously can be
made optional.  Then it could be used for audio devices.

-- 
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.