From ee952d0ef6d9b492f3694741208bfd1ea09e73a2 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 23 Mar 2007 23:02:33 +0000 Subject: [PATCH] MFp4: Create an ivar for each iic device on the iicbus. This ivar holds the device's address. --- sys/dev/iicbus/iicbus.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/dev/iicbus/iicbus.h b/sys/dev/iicbus/iicbus.h index f0c061ca5d7..55f3b937aa4 100644 --- a/sys/dev/iicbus/iicbus.h +++ b/sys/dev/iicbus/iicbus.h @@ -29,13 +29,36 @@ #ifndef __IICBUS_H #define __IICBUS_H -struct iicbus_softc { +#define IICBUS_IVAR(d) (struct iicbus_ivar *) device_get_ivars(d) +#define IICBUS_SOFTC(d) (struct iicbus_softc *) device_get_softc(d) +struct iicbus_softc +{ + device_t dev; /* Myself */ device_t owner; /* iicbus owner device structure */ u_char started; /* address of the 'started' slave * 0 if no start condition succeeded */ }; +struct iicbus_ivar +{ + uint32_t addr; +}; + +enum { + IICBUS_IVAR_ADDR /* Address or base address */ +}; + +#define IICBUS_ACCESSOR(A, B, T) \ +__inline static int \ +iicbus_get_ ## A(device_t dev, T *t) \ +{ \ + return BUS_READ_IVAR(device_get_parent(dev), dev, \ + IICBUS_IVAR_ ## B, (uintptr_t *) t); \ +} + +IICBUS_ACCESSOR(addr, ADDR, uint32_t) + extern int iicbus_generic_intr(device_t dev, int event, char *buf); extern driver_t iicbus_driver;