diff options
author | piso <piso@FreeBSD.org> | 2007-05-31 19:29:20 +0000 |
---|---|---|
committer | piso <piso@FreeBSD.org> | 2007-05-31 19:29:20 +0000 |
commit | b5a7cab3ba8571b11307ccdf9f85c2a5408aa1d0 (patch) | |
tree | 1b5e7f16e434a83f7966afb0d03cfe1e42838808 /sys/dev/pccbb | |
parent | 42dfc7815053cf9eda064a398dd5f2e1efa583ca (diff) | |
download | FreeBSD-src-b5a7cab3ba8571b11307ccdf9f85c2a5408aa1d0.zip FreeBSD-src-b5a7cab3ba8571b11307ccdf9f85c2a5408aa1d0.tar.gz |
Make the interrupt handler wrapper capable of correctly support filter+ithread handler.
Discussed and reviewed with: bsdimp, simokawa
Diffstat (limited to 'sys/dev/pccbb')
-rw-r--r-- | sys/dev/pccbb/pccbb.c | 29 | ||||
-rw-r--r-- | sys/dev/pccbb/pccbbvar.h | 1 |
2 files changed, 22 insertions, 8 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index 339bf13..78f8704 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/module.h> #include <sys/kthread.h> +#include <sys/interrupt.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.h> @@ -176,6 +177,7 @@ static int cbb_cardbus_power_enable_socket(device_t brdev, device_t child); static void cbb_cardbus_power_disable_socket(device_t brdev, device_t child); +static int cbb_func_filt(void *arg); static void cbb_func_intr(void *arg); static void @@ -365,18 +367,19 @@ cbb_setup_intr(device_t dev, device_t child, struct resource *irq, struct cbb_softc *sc = device_get_softc(dev); int err; + if (filt == NULL && intr == NULL) + return (EINVAL); /* * Well, this is no longer strictly true. You can have multiple * FAST ISRs, but can't mix fast and slow, so we have to assume * least common denominator until the base system supports mixing * and matching better. */ - if (filt != NULL) - return (EINVAL); ih = malloc(sizeof(struct cbb_intrhand), M_DEVBUF, M_NOWAIT); if (ih == NULL) return (ENOMEM); *cookiep = ih; + ih->filt = filt; ih->intr = intr; ih->arg = arg; ih->sc = sc; @@ -385,7 +388,7 @@ cbb_setup_intr(device_t dev, device_t child, struct resource *irq, * XXX for now that's all we need to do. */ err = BUS_SETUP_INTR(device_get_parent(dev), child, irq, flags, - NULL, cbb_func_intr, ih, &ih->cookie); + cbb_func_filt, cbb_func_intr, ih, &ih->cookie); if (err != 0) { free(ih, M_DEVBUF); return (err); @@ -612,8 +615,8 @@ cbb_removal(struct cbb_softc *sc) * cbb_func_intr(), we could just check the SOCKET_MASK register and if * CD changes were clear there, then we'd know the card was gone. */ -static void -cbb_func_intr(void *arg) +static int +cbb_func_filt(void *arg) { struct cbb_intrhand *ih = (struct cbb_intrhand *)arg; struct cbb_softc *sc = ih->sc; @@ -622,17 +625,27 @@ cbb_func_intr(void *arg) * Make sure that the card is really there. */ if ((sc->flags & CBB_CARD_OK) == 0) - return; + return (FILTER_STRAY); if (!CBB_CARD_PRESENT(cbb_get(sc, CBB_SOCKET_STATE))) { sc->flags &= ~CBB_CARD_OK; - return; + return (FILTER_STRAY); } /* * nb: don't have to check for giant or not, since that's done * in the ISR dispatch */ - (*ih->intr)(ih->arg); + if (ih->filt != NULL) + return ((*ih->filt)(ih->arg)); + return (FILTER_SCHEDULE_THREAD); +} + +static void +cbb_func_intr(void *arg) +{ + struct cbb_intrhand *ih = (struct cbb_intrhand *)arg; + + ih->intr(ih->arg); } /************************************************************************/ diff --git a/sys/dev/pccbb/pccbbvar.h b/sys/dev/pccbb/pccbbvar.h index 15ea0a0..a9eacdb 100644 --- a/sys/dev/pccbb/pccbbvar.h +++ b/sys/dev/pccbb/pccbbvar.h @@ -32,6 +32,7 @@ */ struct cbb_intrhand { + driver_filter_t *filt; driver_intr_t *intr; void *arg; struct cbb_softc *sc; |