diff --git a/kernel/system/do_irqctl.c b/kernel/system/do_irqctl.c index 7656e2586..67d414802 100644 --- a/kernel/system/do_irqctl.c +++ b/kernel/system/do_irqctl.c @@ -81,22 +81,32 @@ PUBLIC int do_irqctl(struct proc * caller, message * m_ptr) } } - /* Find a free IRQ hook for this mapping. */ - hook_ptr = NULL; - for (irq_hook_id=0; irq_hook_idIRQ_HOOK_ID; if (notify_id > CHAR_BIT * sizeof(irq_id_t) - 1) return(EINVAL); + /* Try to find an existing mapping to override. */ + hook_ptr = NULL; + for (i=0; !hook_ptr && im_source + && irq_hooks[i].notify_id == notify_id) { + irq_hook_id = i; + hook_ptr = &irq_hooks[irq_hook_id]; /* existing hook */ + rm_irq_handler(&irq_hooks[irq_hook_id]); + } + } + + /* If there is nothing to override, find a free hook for this mapping. */ + for (i=0; !hook_ptr && iproc_nr_e = m_ptr->m_source; /* process to notify */ hook_ptr->notify_id = notify_id; /* identifier to pass */