Skip to content

Commit 0a04767

Browse files
kamnxtkartben
authored andcommitted
drivers: serial: stm32: don't allow async TX on a suspended UART
Return an error if trying to send data using a suspended UART, instead of blocking, possibly forever, for a transmission that will never succeed. Signed-off-by: Kamil Krzyżanowski <[email protected]>
1 parent 9defa3c commit 0a04767

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/serial/uart_stm32.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,15 @@ static int uart_stm32_async_tx(const struct device *dev,
16751675
__maybe_unused unsigned int key;
16761676
int ret;
16771677

1678+
#if defined(CONFIG_PM_DEVICE)
1679+
enum pm_device_state state;
1680+
1681+
(void)pm_device_state_get(dev, &state);
1682+
if (state != PM_DEVICE_STATE_ACTIVE) {
1683+
return -ECANCELED;
1684+
}
1685+
#endif
1686+
16781687
/* Check size of singl character (1 or 2 bytes) */
16791688
const int char_size = (IS_ENABLED(CONFIG_UART_WIDE_DATA) &&
16801689
(LL_USART_GetDataWidth(usart) == LL_USART_DATAWIDTH_9B) &&

0 commit comments

Comments
 (0)