Skip to content

Commit 722ccf4

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
serial: atmel: fix error handling when mctrl_gpio_init fails
mctrl_gpio_init at present doesn't return NULL. (It might be used in the future when no gpios are to be used indicating success.) Properly pass error returned and also make driver probing fail on error. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c89b737 commit 722ccf4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/tty/serial/atmel_serial.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,8 +2542,8 @@ static int atmel_init_gpios(struct atmel_uart_port *p, struct device *dev)
25422542
struct gpio_desc *gpiod;
25432543

25442544
p->gpios = mctrl_gpio_init(dev, 0);
2545-
if (IS_ERR_OR_NULL(p->gpios))
2546-
return -1;
2545+
if (IS_ERR(p->gpios))
2546+
return PTR_ERR(p->gpios);
25472547

25482548
for (i = 0; i < UART_GPIO_MAX; i++) {
25492549
gpiod = mctrl_gpio_to_gpiod(p->gpios, i);
@@ -2594,9 +2594,10 @@ static int atmel_serial_probe(struct platform_device *pdev)
25942594
port->uart.line = ret;
25952595

25962596
ret = atmel_init_gpios(port, &pdev->dev);
2597-
if (ret < 0)
2598-
dev_err(&pdev->dev, "%s",
2599-
"Failed to initialize GPIOs. The serial port may not work as expected");
2597+
if (ret < 0) {
2598+
dev_err(&pdev->dev, "Failed to initialize GPIOs.");
2599+
goto err;
2600+
}
26002601

26012602
ret = atmel_init_port(port, pdev);
26022603
if (ret)

0 commit comments

Comments
 (0)