Skip to content

Commit

Permalink
irq: multilevel: reduce the use of macros
Browse files Browse the repository at this point in the history
Convert `#if defined CONFIG_*` to use
`if (IS_ENABLED(CONFIG_*))` and removed some macro guards since
they are safe to be compile.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
  • Loading branch information
ycsin committed Nov 6, 2023
1 parent 156a642 commit dd604b2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions include/zephyr/irq_multilevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ static inline unsigned int irq_get_level(unsigned int irq)
return 1;
}

#if defined(CONFIG_2ND_LEVEL_INTERRUPTS)
/**
* @brief Return the 2nd level interrupt number
*
Expand All @@ -58,12 +57,12 @@ static inline unsigned int irq_get_level(unsigned int irq)
*/
static inline unsigned int irq_from_level_2(unsigned int irq)
{
#if defined(CONFIG_3RD_LEVEL_INTERRUPTS)
return ((irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS)) - 1;
#else
return (irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) - 1;
#endif
if (IS_ENABLED(CONFIG_3RD_LEVEL_INTERRUPTS)) {
return ((irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS)) - 1;
} else {
return (irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) - 1;
}
}

/**
Expand Down Expand Up @@ -106,9 +105,7 @@ static inline unsigned int irq_parent_level_2(unsigned int irq)
{
return irq & BIT_MASK(CONFIG_1ST_LEVEL_INTERRUPT_BITS);
}
#endif

#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
/**
* @brief Return the 3rd level interrupt number
*
Expand Down Expand Up @@ -167,7 +164,6 @@ static inline unsigned int irq_parent_level_3(unsigned int irq)
return (irq >> CONFIG_1ST_LEVEL_INTERRUPT_BITS) &
BIT_MASK(CONFIG_2ND_LEVEL_INTERRUPT_BITS);
}
#endif

#ifdef __cplusplus
}
Expand Down

0 comments on commit dd604b2

Please sign in to comment.