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;