1 /* $FreeBSD$ */ 2 3 #define SPIBUS_IVAR(d) (struct spibus_ivar *) device_get_ivars(d) 4 #define SPIBUS_SOFTC(d) (struct spibus_softc *) device_get_softc(d) 5 6 struct spibus_softc 7 { 8 device_t dev; 9 }; 10 11 struct spibus_ivar 12 { 13 uint32_t cs; 14 }; 15 16 enum { 17 SPIBUS_IVAR_CS /* chip select that we're on */ 18 }; 19 20 #define SPIBUS_ACCESSOR(A, B, T) \ 21 static inline int \ 22 spibus_get_ ## A(device_t dev, T *t) \ 23 { \ 24 return BUS_READ_IVAR(device_get_parent(dev), dev, \ 25 SPIBUS_IVAR_ ## B, (uintptr_t *) t); \ 26 } 27 28 SPIBUS_ACCESSOR(cs, CS, uint32_t) 29