Skip to content

Commit 793065c

Browse files
ycsinnashif
authored andcommitted
irq: multilevel: fix irq_parent_level_3()
The IRQ for level 1 and above is incremented by 1 when encoded with Zephyr's multilevel IRQ scheme, so it should be decremented by 1. Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 22b72e6 commit 793065c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

include/zephyr/irq_multilevel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ static inline unsigned int irq_to_level_3(unsigned int irq)
163163
*/
164164
static inline unsigned int irq_parent_level_3(unsigned int irq)
165165
{
166-
return (irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
167-
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS);
166+
return ((irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
167+
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS)) -
168+
1;
168169
}
169170

170171
/**

tests/kernel/gen_isr_table/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ static void test_multi_level_bit_masks_fn(uint32_t irq1, uint32_t irq2, uint32_t
437437
zassert_equal(hwirq3, irq_from_level(irqn, 3));
438438
zassert_equal((hwirq3 + 1) << l3_shift, irq_to_level_3(hwirq3));
439439
zassert_equal((hwirq3 + 1) << l3_shift, irq_to_level(hwirq3, 3));
440-
zassert_equal(hwirq2 + 1, irq_parent_level_3(irqn));
441-
zassert_equal(hwirq2 + 1, irq_parent_level(irqn, 3));
440+
zassert_equal(hwirq2, irq_parent_level_3(irqn));
441+
zassert_equal(hwirq2, irq_parent_level(irqn, 3));
442442
}
443443

444444
if (has_l3) {

0 commit comments

Comments
 (0)