Make the interrupt handler wrapper capable of correctly support filter+ithread handler.
Discussed and reviewed with: bsdimp, simokawa
This commit is contained in:
parent
42dfc78150
commit
b5a7cab3ba
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -32,6 +32,7 @@
|
||||
*/
|
||||
|
||||
struct cbb_intrhand {
|
||||
driver_filter_t *filt;
|
||||
driver_intr_t *intr;
|
||||
void *arg;
|
||||
struct cbb_softc *sc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user