diff options
author | John Baldwin <jhb@FreeBSD.org> | 2012-10-15 16:09:59 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2012-10-15 16:09:59 +0000 |
commit | 4bb96a74189d70a5ddb6c5f291d43c6e779997ec (patch) | |
tree | 5829ecb29696b68ee5df08cafc2d610e3430d0bd /sys/dev/aic/aic_isa.c | |
parent | e40cc6afc410638f9990b0cfad494f9b58a3c129 (diff) | |
download | src-4bb96a74189d70a5ddb6c5f291d43c6e779997ec.tar.gz src-4bb96a74189d70a5ddb6c5f291d43c6e779997ec.zip |
Add locking to the aic(4) driver and mark it MPSAFE.
- Move 'free_scbs' into the softc rather than having it be a global list
and convert it to an SLIST instead of a hand-rolled linked-list.
- Use device_printf() and device_get_unit() instead of storing the unit
number in the softc.
- Remove use of explicit bus space handles and tags.
- Don't call device_set_desc() in the pccard attach routine, instead
set a default description during the pccard probe if the matching
product doesn't have a name.
Tested by: no one
Notes
Notes:
svn path=/head/; revision=241591
Diffstat (limited to 'sys/dev/aic/aic_isa.c')
-rw-r--r-- | sys/dev/aic/aic_isa.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/dev/aic/aic_isa.c b/sys/dev/aic/aic_isa.c index b80b3873363b..1671802863c5 100644 --- a/sys/dev/aic/aic_isa.c +++ b/sys/dev/aic/aic_isa.c @@ -28,8 +28,11 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> +#include <sys/callout.h> #include <sys/kernel.h> +#include <sys/lock.h> #include <sys/module.h> +#include <sys/mutex.h> #include <sys/bus.h> #include <machine/bus.h> @@ -69,7 +72,7 @@ aic_isa_alloc_resources(device_t dev) struct aic_isa_softc *sc = device_get_softc(dev); int rid; - sc->sc_port = sc->sc_irq = sc->sc_drq = 0; + sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; rid = 0; sc->sc_port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, @@ -102,9 +105,8 @@ aic_isa_alloc_resources(device_t dev) } sc->sc_aic.dev = dev; - sc->sc_aic.unit = device_get_unit(dev); - sc->sc_aic.tag = rman_get_bustag(sc->sc_port); - sc->sc_aic.bsh = rman_get_bushandle(sc->sc_port); + sc->sc_aic.res = sc->sc_port; + mtx_init(&sc->sc_aic.lock, "aic", NULL, MTX_DEF); return (0); } @@ -119,7 +121,8 @@ aic_isa_release_resources(device_t dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq); if (sc->sc_drq) bus_release_resource(dev, SYS_RES_DRQ, 0, sc->sc_drq); - sc->sc_port = sc->sc_irq = sc->sc_drq = 0; + sc->sc_port = sc->sc_irq = sc->sc_drq = NULL; + mtx_destroy(&sc->sc_aic.lock); } static int @@ -149,10 +152,8 @@ aic_isa_probe(device_t dev) continue; if (aic_isa_alloc_resources(dev)) continue; - if (!aic_probe(aic)) { - aic_isa_release_resources(dev); + if (aic_probe(aic) == 0) break; - } aic_isa_release_resources(dev); } @@ -160,6 +161,7 @@ aic_isa_probe(device_t dev) return (ENXIO); porta = aic_inb(aic, PORTA); + aic_isa_release_resources(dev); if (isa_get_irq(dev) == -1) bus_set_resource(dev, SYS_RES_IRQ, 0, PORTA_IRQ(porta), 1); if ((aic->flags & AIC_DMA_ENABLE) && isa_get_drq(dev) == -1) @@ -188,8 +190,8 @@ aic_isa_attach(device_t dev) return (error); } - error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM|INTR_ENTROPY, - NULL, aic_intr, aic, &sc->sc_ih); + error = bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_CAM | INTR_ENTROPY | + INTR_MPSAFE, NULL, aic_intr, aic, &sc->sc_ih); if (error) { device_printf(dev, "failed to register interrupt handler\n"); aic_isa_release_resources(dev); |