Atheros的AP83的解决方案中,gpio的中断服务程序中设置了一个中断处理函数的入口,这个入口可以在其他方便的驱动程序中注册,就像一个钩子函数,感觉用法挺不错的,现在把它的框架记录下来。
int __init pbXX_simple_config_init(void)
{
req = request_irq (AR7100_GPIO_IRQn(JUMPSTART_GPIO), jumpstart_irq, 0,
"SW JUMPSTART", NULL);
return 0;
}
irqreturn_t jumpstart_irq(int cpl, void *dev_id, struct pt_regs *regs)
{
printk ("calling simple_config callback../n");
if (registered_cb) {
return registered_cb (cpl, cb_arg, regs);
}
return IRQ_HANDLED;
}
typedef irqreturn_t(*sc_callback_t)(int, void *, struct pt_regs *);
static sc_callback_t registered_cb = NULL;
static void *cb_arg;
void register_simple_config_callback (void *callback, void *arg)
{
registered_cb = (sc_callback_t) callback;
cb_arg = arg;
}
EXPORT_SYMBOL(register_simple_config_callback);
void unregister_simple_config_callback (void)
{
registered_cb = NULL;
cb_arg = NULL;
}
EXPORT_SYMBOL(unregister_simple_config_callback);
In madwifi driver
/* Request Simple Config intr handler */
register_simple_config_callback ((void *) jumpstart_intr, (void *) dev);
/*
* Handler for front panel SW jumpstart switch
*/
static irqreturn_t
jumpstart_intr (int cpl, void *dev_id, struct pt_regs *regs)
{
struct net_device *dev = dev_id;
struct ath_softc_net80211 *scn = dev->priv;
struct ieee80211com *ic = &scn->sc_ic;
struct ieee80211vap *vap;
vap = TAILQ_FIRST(&ic->ic_vaps);
if (vap != NULL) {
ieee80211_notify_push_button (vap);
}
return IRQ_HANDLED;
}
这个函数就是这个GPIO中断最后对应的处理函数。
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>