Subject: Re: "esp" driver reorg proposal
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: J. Koenig-Baltes <joachim@sz-sb.de>
List: tech-kern
Date: 01/31/1997 09:24:50
Jason Thorpe wrote:
> Now, if we think about the case where you have a FooBar ZapStation,
> which comes in the Whuzzle and Zoobie models, each of which have
> an NCR53c94 on very different busses, you'd have to do dispatching
> for each macro call. I.e., take the case of ESP_READ_REG():
>
> static __inline u_char ESP_READ_REG __P((struct esp_softc *, int));
> static __inline u_char
> ESP_READ_REG(sc, reg)
> struct esp_softc *sc;
> int reg;
> {
> u_char v;
>
> if (sc->sc_bustype == WHUZZLE) {
> /* do Whuzzle stuff */
> } else {
> /* so Zoobie stuff */
> }
>
> return (v);
> }
>
> That has the possiblity of unnecessarily increasing code size, and
> paying the cost of extra comparisons, as more ZapStation models
> are introduced. Also, it may be necessary to call bus-specific
> functions inside of this macro or inline, which inappropriately
> exposes that bus to the outside world.
>
> This just makes me feel better about setting up a set of function
> pointers once at attach time.
Although the machine-independent driver would support a number of different
busses, this overhead could be avoided if I know that I have the chip at
a specific bus, by compiling with specific bus support, e.g.:
gcc -DESP_SUPPORT_WHUZZLE=1 -DESP_SUPPORT_ZOOBIE=0 .....
and having the source look like:
static __inline u_char
ESP_READ_REG(sc, reg)
struct esp_softc *sc;
int reg;
{
u_char v;
#if ESP_SUPPORT_WHUZZLE + ESP_SUPPORT_ZOOBIE > 1
switch (sc->sc_bustype) {
#if ESP_SUPPORT_WHUZZLE > 0
case WHUZZLE:
#endif
#if ESP_SUPPORT_WHUZZLE > 0
/* do Whuzzle stuff */
#endif
#if ESP_SUPPORT_WHUZZLE + ESP_SUPPORT_ZOOBIE > 1
break;
#if ESP_SUPPORT_ZOOBIE > 0
case ZOOBIE:
#endif
#endif
#if ESP_SUPPORT_ZOOBIE > 0
/* so Zoobie stuff */
#endif
#if ESP_SUPPORT_WHUZZLE + ESP_SUPPORT_ZOOBIE > 1
break;
}
#endif
return (v);
}
Looks a bit ugly, but avoids increasing code size and paying the cost of
extra comparisons for customized kernels.
Joachim