drivers: serial: stm32: store IRQ config function in a single place
When CONFIG_PM=y, the IRQ function also needs to be stored, something the "generic" uart_device_config cannot support. This uses the config irq_config_func field to store the function in all situations, thus removing unnecessary logic and finally dropping uart_device_config. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
32a3a028f2
commit
e101cc78e9
2 changed files with 9 additions and 19 deletions
|
@ -1620,11 +1620,11 @@ static int uart_stm32_init(const struct device *dev)
|
|||
}
|
||||
#endif /* !USART_ISR_REACK */
|
||||
|
||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API)
|
||||
config->uconf.irq_config_func(dev);
|
||||
#elif defined(CONFIG_PM)
|
||||
#if defined(CONFIG_PM) || \
|
||||
defined(CONFIG_UART_INTERRUPT_DRIVEN) || \
|
||||
defined(CONFIG_UART_ASYNC_API)
|
||||
config->irq_config_func(dev);
|
||||
#endif /* defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) */
|
||||
#endif /* CONFIG_PM || CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API */
|
||||
|
||||
#ifdef CONFIG_UART_ASYNC_API
|
||||
return uart_stm32_async_init(dev);
|
||||
|
@ -1681,17 +1681,12 @@ static void uart_stm32_irq_config_func_##index(const struct device *dev) \
|
|||
#define STM32_UART_IRQ_HANDLER(index) /* Not used */
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API)
|
||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
|
||||
defined(CONFIG_PM)
|
||||
#define STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||
.irq_config_func = uart_stm32_irq_config_func_##index,
|
||||
#define STM32_UART_POLL_IRQ_HANDLER_FUNC(index) /* Not used */
|
||||
#elif defined(CONFIG_PM)
|
||||
#define STM32_UART_IRQ_HANDLER_FUNC(index) /* Not used */
|
||||
#define STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
|
||||
.irq_config_func = uart_stm32_irq_config_func_##index,
|
||||
#else
|
||||
#define STM32_UART_IRQ_HANDLER_FUNC(index) /* Not used */
|
||||
#define STM32_UART_POLL_IRQ_HANDLER_FUNC(index) /* Not used */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_ASYNC_API
|
||||
|
@ -1713,9 +1708,6 @@ PINCTRL_DT_INST_DEFINE(index); \
|
|||
\
|
||||
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||
.usart = (USART_TypeDef *)DT_INST_REG_ADDR(index), \
|
||||
.uconf = { \
|
||||
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||
}, \
|
||||
.pclken = { .bus = DT_INST_CLOCKS_CELL(index, bus), \
|
||||
.enr = DT_INST_CLOCKS_CELL(index, bits) \
|
||||
}, \
|
||||
|
@ -1723,7 +1715,7 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
|||
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
||||
.single_wire = DT_INST_PROP_OR(index, single_wire, false), \
|
||||
STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
|
||||
STM32_UART_IRQ_HANDLER_FUNC(index) \
|
||||
}; \
|
||||
\
|
||||
static struct uart_stm32_data uart_stm32_data_##index = { \
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
struct uart_stm32_config {
|
||||
/* USART instance */
|
||||
USART_TypeDef *usart;
|
||||
struct uart_device_config uconf;
|
||||
/* clock subsystem driving this peripheral */
|
||||
struct stm32_pclken pclken;
|
||||
/* initial hardware flow control, 1 for RTS/CTS */
|
||||
|
@ -30,9 +29,8 @@ struct uart_stm32_config {
|
|||
/* switch to enable single wire / half duplex feature */
|
||||
bool single_wire;
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
#if defined(CONFIG_PM) \
|
||||
&& !defined(CONFIG_UART_INTERRUPT_DRIVEN) \
|
||||
&& !defined(CONFIG_UART_ASYNC_API)
|
||||
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) || \
|
||||
defined(CONFIG_PM)
|
||||
uart_irq_config_func_t irq_config_func;
|
||||
#endif
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue