From bde1cd8d38fee1ff64c78f715ad34672be323c6c Mon Sep 17 00:00:00 2001 From: "Kenneth J. Miller" Date: Fri, 23 Jun 2023 04:24:49 +0200 Subject: [PATCH] drivers: serial: stm32: Move boot-time config to data Move reset configuration from uart_stm32_data to const uart_stm32_config struct, as this is set once at boot and isn't modified during runtime. Signed-off-by: Kenneth J. Miller --- drivers/serial/uart_stm32.c | 6 +++--- drivers/serial/uart_stm32.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 47149a1de11..8f74bf2868a 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1853,13 +1853,13 @@ static int uart_stm32_init(const struct device *dev) LL_USART_Disable(config->usart); - if (!device_is_ready(data->reset.dev)) { + if (!device_is_ready(config->reset.dev)) { LOG_ERR("reset controller not ready"); return -ENODEV; } /* Reset UART to default state using RCC */ - (void)reset_line_toggle_dt(&data->reset); + (void)reset_line_toggle_dt(&config->reset); /* TX/RX direction */ LL_USART_SetTransferDirection(config->usart, @@ -2143,6 +2143,7 @@ static const struct stm32_pclken pclken_##index[] = \ \ static const struct uart_stm32_config uart_stm32_cfg_##index = { \ .usart = (USART_TypeDef *)DT_INST_REG_ADDR(index), \ + .reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \ .pclken = pclken_##index, \ .pclk_len = DT_INST_NUM_CLOCKS(index), \ .hw_flow_control = DT_INST_PROP(index, hw_flow_control), \ @@ -2162,7 +2163,6 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \ \ static struct uart_stm32_data uart_stm32_data_##index = { \ .baud_rate = DT_INST_PROP(index, current_speed), \ - .reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \ UART_DMA_CHANNEL(index, rx, RX, PERIPHERAL, MEMORY) \ UART_DMA_CHANNEL(index, tx, TX, MEMORY, PERIPHERAL) \ }; \ diff --git a/drivers/serial/uart_stm32.h b/drivers/serial/uart_stm32.h index 81507adf457..536b8200d35 100644 --- a/drivers/serial/uart_stm32.h +++ b/drivers/serial/uart_stm32.h @@ -22,6 +22,8 @@ struct uart_stm32_config { /* USART instance */ USART_TypeDef *usart; + /* Reset controller device configuration */ + const struct reset_dt_spec reset; /* clock subsystem driving this peripheral */ const struct stm32_pclken *pclken; /* number of clock subsystems */ @@ -84,8 +86,6 @@ struct uart_stm32_data { uint32_t baud_rate; /* clock device */ const struct device *clock; - /* Reset controller device configuration */ - const struct reset_dt_spec reset; #ifdef CONFIG_UART_INTERRUPT_DRIVEN uart_irq_callback_user_data_t user_cb; void *user_data;