tech-kern archive

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

Re: Inter-driver #if dependencies



> On May 17, 2015, at 3:40 PM, Paul Goyette <paul%vps1.whooppee.com@localhost> wrote:
> 
> My crusade for modularity has arrived at the pcppi(4) driver, and I've discovered that there are a number of places in the code where a #if is used to determine whether or not some _other_ driver is available to provide certain routines.  For pcppi(4), these dependencies are for the attimer(4) and pckbd(4) drivers.  (While I haven't yet gone searching, I'd be willing to wager that there are other similar examples in other drivers.)
> 
> These #if constructs make it very difficult to modularize these drivers.
> 
> I'd like to propose the following new kernel mechanism that will allow us to remove these #if dependencies.
> 
> 1. Extend the struct cfattach to have an additional member, and create
>  a new CFATTACH_DECL4_NEW macro to initialize it (and updates to the
>  existing CFATTACH_* family to default the value to NULL).
> 
> 	int	(*ca_callback)(device_t, int, void *);
> 
>  (This will require a kernel version bump.)

Ewww.  Gross.

It might be better to use weak symbols and then fix them up later.



Home | Main Index | Thread Index | Old Index