Skip to content

Commit 2fc2928

Browse files
Andrei-Edward Popanashif
authored andcommitted
drivers: serial: rpi_pico: check if baudrate was set by the API function
if peripheral clock is not configured, uart init API function returns 0, so we need to check the return value of this function Signed-off-by: Andrei-Edward Popa <[email protected]>
1 parent 044594e commit 2fc2928

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/serial/uart_rpi_pico.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,21 @@ static void uart_rpi_poll_out(const struct device *dev, unsigned char c)
4040
static int uart_rpi_init(const struct device *dev)
4141
{
4242
const struct uart_rpi_config *config = dev->config;
43-
int ret;
43+
uart_inst_t * const uart_inst = config->uart_dev;
44+
uart_hw_t * const uart_hw = config->uart_regs;
45+
struct uart_rpi_data * const data = dev->data;
46+
int ret, baudrate;
4447

4548
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
4649
if (ret < 0) {
4750
return ret;
4851
}
4952

50-
uart_init(config->uart_dev, config->baudrate);
53+
baudrate = uart_init(uart_inst, data->baudrate);
54+
/* Check if baudrate adjustment returned by 'uart_init' function is a positive value */
55+
if (baudrate <= 0) {
56+
return -EINVAL;
57+
}
5158

5259
return 0;
5360
}

0 commit comments

Comments
 (0)