Subject: Newbie questions about drivers
To: None <>
From: Peter Seebach <>
List: tech-kern
Date: 03/18/2006 11:27:06
So, I'm starting on the NAND stuff.  And some of this is easy and obvious.

Some of it isn't, and I'm guessing there's some essential element of the
organization here I don't get.

I basically follow the struct cfattach.  What I don't understand is why
the struct cfattach objects are declared in such very odd ways.  For instance,
consider the 15-line macro that declares, indirectly, "usb_ca":

	#define USB_DECLARE_DRIVER(dname)  \
	const struct cfattach __CONCAT(dname,_ca) = { \
		sizeof(struct __CONCAT(dname,_softc)), \
		__CONCAT(dname,_match), \
		__CONCAT(dname,_attach), \
		__CONCAT(dname,_detach), \
		__CONCAT(dname,_activate), \

So, what I'm not getting is:

* Since I can't see any reason for any driver's cfattach not to look like
this, why is this in a USB header?
* Am I right in thinking that it's actually config that will generate a table
that includes the reference to usb_ca?

More generally, the procedure by which devices get into cdevsw is not obvious
to me; for instance, where is the information used to decide where rnd_cdevsw
goes?  I can't find any reference to rnd in ***/files.*, or in config's
source.  But obviously it comes from SOMEWHERE.