Subject: Re: bus space macros for structures
To: Michael Richardson <mcr@sandelman.ottawa.on.ca>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: tech-kern
Date: 02/04/1997 10:27:17
In a couple of drivers I did the following:
struct amcc593xreg{
[...]
u_int intcsr;
[...]
};
struct pcivic_softc{
[...]
bus_chipset_tag_t sc_bc;
[...]
bus_mem_handle_t amccbase;
[...]
};
#define ofs(what, elem) ((int)&(((what *)0)->elem))
#define readamcc(sc, reg) (bus_mem_read_4(sc->sc_bc, sc->amccbase, \
ofs(struct amcc593xreg, reg)))
[...]
intcsr = readamcc(sc, intcsr);
Is this good because it keeps the namespace clean, or
is it bad because it combines the complexity of
bus_space_xxx() with the non-portability of structs?
Other ideas how to accomplish the clean namespace
(and some consistency checks).
best regards
Matthias Drochner