tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mjf-devfs2 branch

On Sat, Mar 29, 2008 at 04:35:31PM +0000, Matt Fleming wrote:
> Hash: SHA1
> As some of you may know I've been working devfs support for NetBSD as
> part of a project for my final year at the University of Leeds.



> Now, for device driver conversion. I've provided an API that device drivers
> can use when they need device nodes,
> int device_register_name(dev_t, device_t, boolean_t, enum devtype, 
>       const char *, ...);

You need to add something to indicate if the dev_t is a character or block 

> 'devtype' specifies the type of device which will be used for matching rules.
> See sys/sys/conf.h for details.
> int device_unregister_name(dev_t, const char *, ...);
> We maintain a TAILQ of structs which is appended with the register function
> and has entries removed with the unregister function. When a new struct is
> added to this queue dctl(4) creates a message and places it on an internal
> queue which is picked up by devfsd(8).

Ok, while I can see the need for an unregister_name(), I think what you
really want is device_unregister_all(dev_t, is_block) which zapps
everything for that device.

Saves snprintf()s in detatch. :-)

Actually, if you pass in the device_t, just have 
device_unregister(device_t) and blow away anything keyed to that device.

> Now, an example of how to convert a device driver,
> void
> mydriver_attach(struct device *parent, struct device *self, void *aux)
> {
>       int major = cdevsw_lookup_major(&mydriver_cdevsw);
>       int unit = device_unit(self);
>       device_register_name(makedev(major, unit), self, true, 
>           DEV_OTHER, "mydriver%d", unit);
> }
> int
> mydriver_detach(struct device *self, int flags)
> {
>       int major = cdevsw_lookup_major(&mydriver_cdevsw);
>       int unit = device_unit(self);
>       device_unregister_name(makedev(major, unit), "mydriver%d", unit);
>       return 0;
> }

Take care,


Attachment: pgpxcTMfePs5I.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index