Skip to content

Commit 79ff645

Browse files
erwangonashif
authored andcommitted
drivers/uart: stm32: Simplify code around pm_constraints handling
Now that we're clearer around pm constraints management in various TX cases (poll streams, irq driven or async), make some code simplifications to ease readability. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent a3de3df commit 79ff645

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

drivers/serial/uart_stm32.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,9 @@ static void uart_stm32_dma_rx_flush(const struct device *dev)
834834

835835
#endif /* CONFIG_UART_ASYNC_API */
836836

837-
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API)
837+
#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || \
838+
defined(CONFIG_UART_ASYNC_API) || \
839+
defined(CONFIG_PM)
838840

839841
static void uart_stm32_isr(const struct device *dev)
840842
{
@@ -900,25 +902,7 @@ static void uart_stm32_isr(const struct device *dev)
900902
uart_stm32_err_check(dev);
901903
#endif /* CONFIG_UART_ASYNC_API */
902904
}
903-
#elif defined(CONFIG_PM)
904-
static void uart_stm32_isr(const struct device *dev)
905-
{
906-
USART_TypeDef *UartInstance = UART_STRUCT(dev);
907-
struct uart_stm32_data *data = DEV_DATA(dev);
908-
909-
if (LL_USART_IsActiveFlag_TC(UartInstance)) {
910-
LL_USART_ClearFlag_TC(UartInstance);
911-
LL_USART_DisableIT_TC(UartInstance);
912-
913-
__ASSERT_NO_MSG(data->tx_poll_stream_on);
914-
915-
data->tx_poll_stream_on = false;
916-
917-
/* allow system to suspend, UART has now finished */
918-
uart_stm32_pm_constraint_release(dev);
919-
}
920-
}
921-
#endif /* (CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) */
905+
#endif /* CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API || CONFIG_PM */
922906

923907
#ifdef CONFIG_UART_ASYNC_API
924908

@@ -1141,7 +1125,8 @@ static int uart_stm32_async_tx(const struct device *dev,
11411125
async_timer_start(&data->dma_tx.timeout_work, data->dma_tx.timeout);
11421126

11431127
#ifdef CONFIG_PM
1144-
/* do not allow system to suspend until transmission has completed */
1128+
1129+
/* Do not allow system to suspend until transmission has completed */
11451130
uart_stm32_pm_constraint_set(dev);
11461131
#endif
11471132

0 commit comments

Comments
 (0)