Skip to content

Commit

Permalink
powerpc: Return early if irq_host lookup type is wrong
Browse files Browse the repository at this point in the history
If for some reason the code incrorectly calls the wrong function to
manage the revmap, not only should we warn, we should take action.
However, in the paths we expect to be taken every delivered interrupt
change to WARN_ON_ONCE.  Use the if (WARN_ON(x)) format to get the
unlikely for free.

Signed-off-by: Milton Miller <miltonm@bga.com>
Reviewed-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Milton Miller authored and Benjamin Herrenschmidt committed May 19, 2011
1 parent 3af259d commit 2d44168
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions arch/powerpc/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ void irq_dispose_mapping(unsigned int virq)
return;

host = irq_map[virq].host;
WARN_ON (host == NULL);
if (host == NULL)
if (WARN_ON(host == NULL))
return;

/* Never unmap legacy interrupts */
Expand Down Expand Up @@ -898,7 +897,8 @@ unsigned int irq_radix_revmap_lookup(struct irq_host *host,
struct irq_map_entry *ptr;
unsigned int virq;

WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
if (WARN_ON_ONCE(host->revmap_type != IRQ_HOST_MAP_TREE))
return irq_find_mapping(host, hwirq);

/*
* No rcu_read_lock(ing) needed, the ptr returned can't go under us
Expand All @@ -922,7 +922,8 @@ unsigned int irq_radix_revmap_lookup(struct irq_host *host,
void irq_radix_revmap_insert(struct irq_host *host, unsigned int virq,
irq_hw_number_t hwirq)
{
WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
if (WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE))
return;

if (virq != NO_IRQ) {
mutex_lock(&revmap_trees_mutex);
Expand All @@ -937,7 +938,8 @@ unsigned int irq_linear_revmap(struct irq_host *host,
{
unsigned int *revmap;

WARN_ON(host->revmap_type != IRQ_HOST_MAP_LINEAR);
if (WARN_ON_ONCE(host->revmap_type != IRQ_HOST_MAP_LINEAR))
return irq_find_mapping(host, hwirq);

/* Check revmap bounds */
if (unlikely(hwirq >= host->revmap_data.linear.size))
Expand Down

0 comments on commit 2d44168

Please sign in to comment.