Skip to content

Commit bde1cd8

Browse files
knthmcarlescufi
authored andcommitted
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 <[email protected]>
1 parent 2531d70 commit bde1cd8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

drivers/serial/uart_stm32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,13 +1853,13 @@ static int uart_stm32_init(const struct device *dev)
18531853

18541854
LL_USART_Disable(config->usart);
18551855

1856-
if (!device_is_ready(data->reset.dev)) {
1856+
if (!device_is_ready(config->reset.dev)) {
18571857
LOG_ERR("reset controller not ready");
18581858
return -ENODEV;
18591859
}
18601860

18611861
/* Reset UART to default state using RCC */
1862-
(void)reset_line_toggle_dt(&data->reset);
1862+
(void)reset_line_toggle_dt(&config->reset);
18631863

18641864
/* TX/RX direction */
18651865
LL_USART_SetTransferDirection(config->usart,
@@ -2143,6 +2143,7 @@ static const struct stm32_pclken pclken_##index[] = \
21432143
\
21442144
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
21452145
.usart = (USART_TypeDef *)DT_INST_REG_ADDR(index), \
2146+
.reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \
21462147
.pclken = pclken_##index, \
21472148
.pclk_len = DT_INST_NUM_CLOCKS(index), \
21482149
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
@@ -2162,7 +2163,6 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
21622163
\
21632164
static struct uart_stm32_data uart_stm32_data_##index = { \
21642165
.baud_rate = DT_INST_PROP(index, current_speed), \
2165-
.reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \
21662166
UART_DMA_CHANNEL(index, rx, RX, PERIPHERAL, MEMORY) \
21672167
UART_DMA_CHANNEL(index, tx, TX, MEMORY, PERIPHERAL) \
21682168
}; \

drivers/serial/uart_stm32.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
struct uart_stm32_config {
2323
/* USART instance */
2424
USART_TypeDef *usart;
25+
/* Reset controller device configuration */
26+
const struct reset_dt_spec reset;
2527
/* clock subsystem driving this peripheral */
2628
const struct stm32_pclken *pclken;
2729
/* number of clock subsystems */
@@ -84,8 +86,6 @@ struct uart_stm32_data {
8486
uint32_t baud_rate;
8587
/* clock device */
8688
const struct device *clock;
87-
/* Reset controller device configuration */
88-
const struct reset_dt_spec reset;
8989
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
9090
uart_irq_callback_user_data_t user_cb;
9191
void *user_data;

0 commit comments

Comments
 (0)