Skip to content

Commit 72091b7

Browse files
committed
drivers: serial: stm32: simplify ISR handlers definition
Simplify interrupt handler helper macros by removing STM32_UART_IRQ_HANDLER_DECL(), using STM32_UART_IRQ_HANDLER() only renamed STM32_UART_IRQ_HANDLER_DEFINE() and aggregating where the macro and STM32_UART_IRQ_HANDLER_FUNC() macro are defined. Signed-off-by: Etienne Carriere <[email protected]>
1 parent 278e4f6 commit 72091b7

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

drivers/serial/uart_stm32.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,29 +2517,21 @@ static int uart_stm32_pm_action(const struct device *dev, enum pm_device_action
25172517
STM32_DMA_FEATURES(index, dir)),
25182518
#endif /* CONFIG_UART_ASYNC_API */
25192519

2520-
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
2521-
defined(CONFIG_PM)
2522-
#define STM32_UART_IRQ_HANDLER_DECL(index) \
2523-
static void uart_stm32_irq_config_func_##index(const struct device *dev);
2524-
#define STM32_UART_IRQ_HANDLER(index) \
2520+
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || defined(CONFIG_PM)
2521+
#define STM32_UART_IRQ_HANDLER_DEFINE(index) \
25252522
static void uart_stm32_irq_config_func_##index(const struct device *dev)\
25262523
{ \
25272524
IRQ_CONNECT(DT_INST_IRQN(index), DT_INST_IRQ(index, priority), \
25282525
uart_stm32_isr, DEVICE_DT_INST_GET(index), 0); \
25292526
irq_enable(DT_INST_IRQN(index)); \
25302527
}
2531-
#else
2532-
#define STM32_UART_IRQ_HANDLER_DECL(index) /* Not used */
2533-
#define STM32_UART_IRQ_HANDLER(index) /* Not used */
2534-
#endif
25352528

2536-
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
2537-
defined(CONFIG_PM)
2538-
#define STM32_UART_IRQ_HANDLER_FUNC(index) \
2529+
#define STM32_UART_IRQ_HANDLER_FUNC(index) \
25392530
.irq_config_func = uart_stm32_irq_config_func_##index,
25402531
#else
2532+
#define STM32_UART_IRQ_HANDLER_DEFINE(index) /* Not used */
25412533
#define STM32_UART_IRQ_HANDLER_FUNC(index) /* Not used */
2542-
#endif
2534+
#endif /* CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API || CONFIG_PM */
25432535

25442536
#ifdef CONFIG_UART_ASYNC_API
25452537
#define UART_DMA_CHANNEL(index, dir, DIR, src, dest) \
@@ -2642,7 +2634,7 @@ static int uart_stm32_pm_action(const struct device *dev, enum pm_device_action
26422634
#endif
26432635

26442636
#define STM32_UART_INIT(index) \
2645-
STM32_UART_IRQ_HANDLER_DECL(index) \
2637+
STM32_UART_IRQ_HANDLER_DEFINE(index) \
26462638
\
26472639
PINCTRL_DT_INST_DEFINE(index); \
26482640
\
@@ -2693,8 +2685,6 @@ static int uart_stm32_pm_action(const struct device *dev, enum pm_device_action
26932685
PRE_KERNEL_1, CONFIG_SERIAL_INIT_PRIORITY, \
26942686
&uart_stm32_driver_api); \
26952687
\
2696-
STM32_UART_IRQ_HANDLER(index) \
2697-
\
26982688
STM32_UART_CHECK_DT_PARITY(index) \
26992689
STM32_UART_CHECK_DT_DATA_BITS(index) \
27002690
STM32_UART_CHECK_DT_STOP_BITS_0_5(index) \

0 commit comments

Comments
 (0)