diff options
author | jhb <jhb@FreeBSD.org> | 2008-08-04 20:46:15 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-08-04 20:46:15 +0000 |
commit | 9b394a3293bfa4397c24c6649034b411994dbb72 (patch) | |
tree | 2a244ae80de29ad3e4b277353b095b09dc4a9aba /sys/dev/pcf/envctrl.c | |
parent | 6f12163ca676979b992a474aab9c999d288f57ed (diff) | |
download | FreeBSD-src-9b394a3293bfa4397c24c6649034b411994dbb72.zip FreeBSD-src-9b394a3293bfa4397c24c6649034b411994dbb72.tar.gz |
Add locking to the various iicbus(4) bridge drivers:
- Just grab Giant in the ixp425_iic(4) driver since this driver uses
a shared address/data register window pair to access the actual
I2C registers. None of the other ixp425 drivers lock access to these
shared address/data registers yet and that would need to be done before
this could use any meaningful locking.
- Add locking to the interrupt handler and 'iicbus_reset' methods of the
at91_twi(4) driver.
- Add locking to the pcf(4) driver. Other pcf(4) fixes include:
- Don't needlessly zero the softc.
- Use bus_foo rather than bus_space_foo and remove bus space tag and
handle from softc.
- The lpbb(4) driver just grabs Giant for now. This will be refined later
when ppbus(4) is locked.
- As was done with smbus earlier, move the DRIVER_MODULE() lines to match
the bus driver (either iicbus or iicbb) to the bridge driver into the
bridge drivers.
Tested by: sam (arm/ixp425)
Diffstat (limited to 'sys/dev/pcf/envctrl.c')
-rw-r--r-- | sys/dev/pcf/envctrl.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/pcf/envctrl.c b/sys/dev/pcf/envctrl.c index 8c47958..7c1cb1b 100644 --- a/sys/dev/pcf/envctrl.c +++ b/sys/dev/pcf/envctrl.c @@ -37,13 +37,15 @@ __FBSDID("$FreeBSD$"); */ #include <sys/param.h> -#include <sys/systm.h> #include <sys/bus.h> #include <sys/conf.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/malloc.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/resource.h> +#include <sys/systm.h> #include <sys/uio.h> #include <dev/ofw/ofw_bus.h> @@ -107,7 +109,7 @@ envctrl_attach(device_t dev) int rv = ENXIO; sc = DEVTOSOFTC(dev); - bzero(sc, sizeof(struct pcf_softc)); + mtx_init(&sc->pcf_lock, device_get_nameunit(dev), "pcf", MTX_DEF); /* IO port is mandatory */ sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY, @@ -116,8 +118,6 @@ envctrl_attach(device_t dev) device_printf(dev, "cannot reserve I/O port range\n"); goto error; } - sc->bt_ioport = rman_get_bustag(sc->res_ioport); - sc->bh_ioport = rman_get_bushandle(sc->res_ioport); sc->pcf_flags = device_get_flags(dev); @@ -134,7 +134,7 @@ envctrl_attach(device_t dev) pcf_rst_card(dev, IIC_FASTEST, PCF_DEFAULT_ADDR, NULL); rv = bus_setup_intr(dev, sc->res_irq, - INTR_TYPE_NET /* | INTR_ENTROPY */, + INTR_TYPE_NET | INTR_MPSAFE /* | INTR_ENTROPY */, NULL, pcf_intr, sc, &sc->intr_cookie); if (rv) { device_printf(dev, "could not setup IRQ\n"); @@ -158,6 +158,7 @@ error: bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, sc->res_ioport); } + mtx_destroy(&sc->pcf_lock); return (rv); } @@ -181,10 +182,12 @@ envctrl_detach(device_t dev) } bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, sc->res_ioport); + mtx_destroy(&sc->pcf_lock); return (0); } DRIVER_MODULE(envctrl, ebus, envctrl_driver, envctrl_devclass, 0, 0); +DRIVER_MODULE(iicbus, envctrl, iicbus_driver, iicbus_devclass, 0, 0); MODULE_DEPEND(envctrl, iicbus, PCF_MINVER, PCF_PREFVER, PCF_MAXVER); MODULE_VERSION(envctrl, PCF_MODVER); |