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 | |
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')
-rw-r--r-- | sys/dev/pccard/pccard.c | 35 | ||||
-rw-r--r-- | sys/dev/pccard/pccardvarp.h | 2 | ||||
-rw-r--r-- | sys/dev/pccbb/pccbb.c | 29 | ||||
-rw-r--r-- | sys/dev/pccbb/pccbbvar.h | 1 |
4 files changed, 42 insertions, 25 deletions
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 64e0a7c..989203a 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -118,7 +118,8 @@ static struct resource *pccard_alloc_resource(device_t dev, static int pccard_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); static void pccard_child_detached(device_t parent, device_t dev); -static int pccard_intr(void *arg); +static int pccard_filter(void *arg); +static void pccard_intr(void *arg); static int pccard_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); @@ -1177,7 +1178,7 @@ pccard_child_detached(device_t parent, device_t dev) } static int -pccard_intr(void *arg) +pccard_filter(void *arg) { struct pccard_function *pf = (struct pccard_function*) arg; int reg; @@ -1208,12 +1209,20 @@ pccard_intr(void *arg) doisr = 0; } if (doisr) { - if (pf->filt_handler != NULL) - pf->filt_handler(pf->intr_handler_arg); + if (pf->intr_filter != NULL) + return (pf->intr_filter(pf->intr_handler_arg)); else - pf->intr_handler(pf->intr_handler_arg); + return (FILTER_SCHEDULE_THREAD); } - return (FILTER_HANDLED); + return (FILTER_STRAY); +} + +static void +pccard_intr(void *arg) +{ + struct pccard_function *pf = (struct pccard_function*) arg; + + pf->intr_handler(pf->intr_handler_arg); } static int @@ -1226,19 +1235,13 @@ pccard_setup_intr(device_t dev, device_t child, struct resource *irq, struct pccard_function *pf = ivar->pf; int err; - if (pf->intr_handler != NULL) + if (pf->intr_filter != NULL || pf->intr_handler != NULL) panic("Only one interrupt handler per function allowed"); - if (filt != NULL && intr != NULL) - return (EINVAL); - if (filt != NULL) - err = bus_generic_setup_intr(dev, child, irq, flags, - pccard_intr, NULL, pf, cookiep); - else - err = bus_generic_setup_intr(dev, child, irq, flags, - NULL, (driver_intr_t *)pccard_intr, pf, cookiep); + err = bus_generic_setup_intr(dev, child, irq, flags, pccard_filter, + pccard_intr, pf, cookiep); if (err != 0) return (err); - pf->filt_handler = filt; + pf->intr_filter = filt; pf->intr_handler = intr; pf->intr_handler_arg = arg; pf->intr_handler_cookie = *cookiep; diff --git a/sys/dev/pccard/pccardvarp.h b/sys/dev/pccard/pccardvarp.h index 892a028..e418730 100644 --- a/sys/dev/pccard/pccardvarp.h +++ b/sys/dev/pccard/pccardvarp.h @@ -112,7 +112,7 @@ struct pccard_function { bus_addr_t pf_mfc_iobase; bus_addr_t pf_mfc_iomax; int pf_flags; - driver_filter_t *filt_handler; + driver_filter_t *intr_filter; driver_intr_t *intr_handler; void *intr_handler_arg; void *intr_handler_cookie; 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; |