Commit 2c299de5 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Jason Cooper

irqchip: armada-370-xp: Introduce a is_percpu_irq() helper for readability

This commit introduces a helper function is_percpu_irq(), to be used
when interrupts are mapped to decide which ones are set as per CPU.

This change will allow to extend the list of per cpu interrupts in a less
intrusive fashion; also, it makes the code slightly more readable by keeping
a list of the per CPU interrupts.
Signed-off-by: default avatarEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
Link: https://lkml.kernel.org/r/1425379400-4346-3-git-send-email-maxime.ripard@free-electrons.comSigned-off-by: default avatarJason Cooper <jason@lakedaemon.net>
parent 933a24b0
...@@ -77,6 +77,16 @@ static DEFINE_MUTEX(msi_used_lock); ...@@ -77,6 +77,16 @@ static DEFINE_MUTEX(msi_used_lock);
static phys_addr_t msi_doorbell_addr; static phys_addr_t msi_doorbell_addr;
#endif #endif
static inline bool is_percpu_irq(irq_hw_number_t irq)
{
switch (irq) {
case ARMADA_370_XP_TIMER0_PER_CPU_IRQ:
return true;
default:
return false;
}
}
/* /*
* In SMP mode: * In SMP mode:
* For shared global interrupts, mask/unmask global enable bit * For shared global interrupts, mask/unmask global enable bit
...@@ -86,7 +96,7 @@ static void armada_370_xp_irq_mask(struct irq_data *d) ...@@ -86,7 +96,7 @@ static void armada_370_xp_irq_mask(struct irq_data *d)
{ {
irq_hw_number_t hwirq = irqd_to_hwirq(d); irq_hw_number_t hwirq = irqd_to_hwirq(d);
if (hwirq != ARMADA_370_XP_TIMER0_PER_CPU_IRQ) if (!is_percpu_irq(hwirq))
writel(hwirq, main_int_base + writel(hwirq, main_int_base +
ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS); ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS);
else else
...@@ -98,7 +108,7 @@ static void armada_370_xp_irq_unmask(struct irq_data *d) ...@@ -98,7 +108,7 @@ static void armada_370_xp_irq_unmask(struct irq_data *d)
{ {
irq_hw_number_t hwirq = irqd_to_hwirq(d); irq_hw_number_t hwirq = irqd_to_hwirq(d);
if (hwirq != ARMADA_370_XP_TIMER0_PER_CPU_IRQ) if (!is_percpu_irq(hwirq))
writel(hwirq, main_int_base + writel(hwirq, main_int_base +
ARMADA_370_XP_INT_SET_ENABLE_OFFS); ARMADA_370_XP_INT_SET_ENABLE_OFFS);
else else
...@@ -287,14 +297,14 @@ static int armada_370_xp_mpic_irq_map(struct irq_domain *h, ...@@ -287,14 +297,14 @@ static int armada_370_xp_mpic_irq_map(struct irq_domain *h,
unsigned int virq, irq_hw_number_t hw) unsigned int virq, irq_hw_number_t hw)
{ {
armada_370_xp_irq_mask(irq_get_irq_data(virq)); armada_370_xp_irq_mask(irq_get_irq_data(virq));
if (hw != ARMADA_370_XP_TIMER0_PER_CPU_IRQ) if (!is_percpu_irq(hw))
writel(hw, per_cpu_int_base + writel(hw, per_cpu_int_base +
ARMADA_370_XP_INT_CLEAR_MASK_OFFS); ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
else else
writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS); writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS);
irq_set_status_flags(virq, IRQ_LEVEL); irq_set_status_flags(virq, IRQ_LEVEL);
if (hw == ARMADA_370_XP_TIMER0_PER_CPU_IRQ) { if (is_percpu_irq(hw)) {
irq_set_percpu_devid(virq); irq_set_percpu_devid(virq);
irq_set_chip_and_handler(virq, &armada_370_xp_irq_chip, irq_set_chip_and_handler(virq, &armada_370_xp_irq_chip,
handle_percpu_devid_irq); handle_percpu_devid_irq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment