Skip to content

Commit

Permalink
tty/serial: at91: fix error handling in atmel_serial_probe()
Browse files Browse the repository at this point in the history
-EDEFER error wasn't handle properly by atmel_serial_probe().
As an example, when atmel_serial_probe() is called for the first time, we pass
the test_and_set_bit() test to check whether the port has already been
initalized. Then we call atmel_init_port(), which may return -EDEFER, possibly
returned before by clk_get(). Consequently atmel_serial_probe() used to return
this error code WITHOUT clearing the port bit in the "atmel_ports_in_use" mask.
When atmel_serial_probe() was called for the second time, it used to fail on
the test_and_set_bit() function then returning -EBUSY.

When atmel_serial_probe() fails, this patch make it clear the port bit in the
"atmel_ports_in_use" mask, if needed, before returning the error code.

Signed-off-by: Cyrille Pitchen <[email protected]>
Acked-by: Nicolas Ferre <[email protected]>
Cc: <[email protected]> # 3.12+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Cyrille Pitchen authored and gregkh committed Jan 9, 2015
1 parent d4f6418 commit 6fbb9bd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/tty/serial/atmel_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,7 @@ static int atmel_serial_probe(struct platform_device *pdev)

ret = atmel_init_port(port, pdev);
if (ret)
goto err;
goto err_clear_bit;

if (!atmel_use_pdc_rx(&port->uart)) {
ret = -ENOMEM;
Expand Down Expand Up @@ -2628,6 +2628,8 @@ static int atmel_serial_probe(struct platform_device *pdev)
clk_put(port->clk);
port->clk = NULL;
}
err_clear_bit:
clear_bit(port->uart.line, atmel_ports_in_use);
err:
return ret;
}
Expand Down

0 comments on commit 6fbb9bd

Please sign in to comment.