From dd604b26f6b0907590aca6d02e27e379f68d020f Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Mon, 6 Nov 2023 15:53:50 +0800 Subject: [PATCH] irq: multilevel: reduce the use of macros 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 --- include/zephyr/irq_multilevel.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/include/zephyr/irq_multilevel.h b/include/zephyr/irq_multilevel.h index 7d320ca1419797..3a2b5116602b5c 100644 --- a/include/zephyr/irq_multilevel.h +++ b/include/zephyr/irq_multilevel.h @@ -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 * @@ -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; + } } /** @@ -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 * @@ -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 }