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 <andrei_edward.popa@upb.ro>
This commit is contained in:
parent
044594e14a
commit
2fc2928fa5
1 changed files with 9 additions and 2 deletions
|
@ -40,14 +40,21 @@ static void uart_rpi_poll_out(const struct device *dev, unsigned char c)
|
|||
static int uart_rpi_init(const struct device *dev)
|
||||
{
|
||||
const struct uart_rpi_config *config = dev->config;
|
||||
int ret;
|
||||
uart_inst_t * const uart_inst = config->uart_dev;
|
||||
uart_hw_t * const uart_hw = config->uart_regs;
|
||||
struct uart_rpi_data * const data = dev->data;
|
||||
int ret, baudrate;
|
||||
|
||||
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
uart_init(config->uart_dev, config->baudrate);
|
||||
baudrate = uart_init(uart_inst, data->baudrate);
|
||||
/* Check if baudrate adjustment returned by 'uart_init' function is a positive value */
|
||||
if (baudrate <= 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue