Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 39 additions & 30 deletions sched/irq/irq_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,31 @@ void irqchain_initialize(void)

bool is_irqchain(int ndx, xcpt_t isr)
{
bool ret;

if (g_irqvector[ndx].handler == irq_unexpected_isr ||
g_irqvector[ndx].handler == NULL)
{
return false;
ret = false;
}
else if (g_irqvector[ndx].handler == irqchain_dispatch)
{
return true;
ret = true;
}
else
{
return isr != irq_unexpected_isr;
ret = isr != irq_unexpected_isr;
}

return ret;
}

int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
{
FAR struct irqchain_s *node;
FAR struct irqchain_s *curr;
irqstate_t flags;
int ret = 0;

flags = spin_lock_irqsave(&g_irqchainlock);
if (isr != irq_unexpected_isr)
Expand All @@ -156,47 +161,51 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
{
if (sq_count(&g_irqchainfreelist) < 2)
{
spin_unlock_irqrestore(&g_irqchainlock, flags);
return -ENOMEM;
ret = -ENOMEM;
}
else
{
node = (FAR struct irqchain_s *)
sq_remfirst(&g_irqchainfreelist);
DEBUGASSERT(node != NULL);

node = (FAR struct irqchain_s *)sq_remfirst(&g_irqchainfreelist);
DEBUGASSERT(node != NULL);

node->handler = g_irqvector[ndx].handler;
node->arg = g_irqvector[ndx].arg;
node->next = NULL;
node->handler = g_irqvector[ndx].handler;
node->arg = g_irqvector[ndx].arg;
node->next = NULL;

g_irqvector[ndx].handler = irqchain_dispatch;
g_irqvector[ndx].arg = node;
}
g_irqvector[ndx].handler = irqchain_dispatch;
g_irqvector[ndx].arg = node;

node = (FAR struct irqchain_s *)sq_remfirst(&g_irqchainfreelist);
if (node == NULL)
{
spin_unlock_irqrestore(&g_irqchainlock, flags);
return -ENOMEM;
}
node = (FAR struct irqchain_s *)
sq_remfirst(&g_irqchainfreelist);
if (node == NULL)
{
ret = -ENOMEM;
}
else
{
node->handler = isr;
node->arg = arg;
node->next = NULL;

node->handler = isr;
node->arg = arg;
node->next = NULL;
curr = g_irqvector[ndx].arg;
while (curr->next != NULL)
{
curr = curr->next;
}

curr = g_irqvector[ndx].arg;
while (curr->next != NULL)
{
curr = curr->next;
curr->next = node;
}
}
}

curr->next = node;
}
else
{
irqchain_detach_all(ndx);
}

spin_unlock_irqrestore(&g_irqchainlock, flags);
return OK;
return ret;
}

int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
Expand Down
Loading