Subject: [cb]devsw ...
To: None <tech-kern@netbsd.org>
From: Stefan Grefen <grefen@hprc.tandem.com>
List: tech-kern
Date: 12/02/1998 16:35:09
I just run into a little road-block. 
Not the first time the way the devsw stuff works gets in the way. 
I've hacked up specfs to allow device-node creation from a driver and 
added clone devices. 
Now I want to automaticly create major numbers. The current way NetBSD
handles the devsw stuff is not extensible. And its a real pain to 
maintain conf.c.
For most devices nobody cares about the major/minor numbers anyway
(if the dev entry points to the correct node).

I propose that the [cb]devsw structures are cached by specfs in the 
vnode.  There are only minor modifications needed to make this work and 
take advantage of the cached devsw pointer.

If the driver creates the /dev entry, than by caching the desw pointer and 
enabling the open function to modify it and an additional DeviceID (as 
a replacment for the minor number), most device drivers wouldn't need a 
seperate major/minor number. 
There is no need for bpf, vnd, speaker, audio etc. to have unique major
numbers.

The changes needed are very simple. Instead of passing aroung
the major/minor number to functions that need access to the devsw, 
a pointer to a structure is passed which contains the pointer and
the DeviceID.
They can also be made completly backwards compatible for device drivers,
only functions directly accessing [cb]desw need to be changed.

I know it doesn't work for all devices right now. There has to be some
changes in the way the kernel opens files, when it doesn't go through 
the filesystem, but it would allow a lot of drivers to create devices
nodes dynamicly right now.  

Stefan

--
Stefan Grefen                                Tandem Computers Europe Inc.
grefen@hprc.tandem.com                       High Performance Research Center
Committee, n.:
        A group of men who individually can do nothing but as a group
	decide that nothing can be done.
			-- Fred Allen