diff options
author | Cyrille Pitchen <cyrille.pitchen@atmel.com> | 2014-12-09 08:31:34 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-01-09 17:20:49 -0500 |
commit | 6fbb9bdf0f3fbe23aeff806489791aa876adaffb (patch) | |
tree | 2fca43a968f23a299c29c0382d33599300076f3b /drivers/tty | |
parent | d4f641876a68d1961e30c202709cc2d484f69f6f (diff) |
tty/serial: at91: fix error handling in atmel_serial_probe()
-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 <cyrille.pitchen@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: <stable@vger.kernel.org> # 3.12+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/atmel_serial.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index c6621dc296c0..92a8b263735a 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
@@ -2565,7 +2565,7 @@ static int atmel_serial_probe(struct platform_device *pdev) | |||
2565 | 2565 | ||
2566 | ret = atmel_init_port(port, pdev); | 2566 | ret = atmel_init_port(port, pdev); |
2567 | if (ret) | 2567 | if (ret) |
2568 | goto err; | 2568 | goto err_clear_bit; |
2569 | 2569 | ||
2570 | if (!atmel_use_pdc_rx(&port->uart)) { | 2570 | if (!atmel_use_pdc_rx(&port->uart)) { |
2571 | ret = -ENOMEM; | 2571 | ret = -ENOMEM; |
@@ -2628,6 +2628,8 @@ err_alloc_ring: | |||
2628 | clk_put(port->clk); | 2628 | clk_put(port->clk); |
2629 | port->clk = NULL; | 2629 | port->clk = NULL; |
2630 | } | 2630 | } |
2631 | err_clear_bit: | ||
2632 | clear_bit(port->uart.line, atmel_ports_in_use); | ||
2631 | err: | 2633 | err: |
2632 | return ret; | 2634 | return ret; |
2633 | } | 2635 | } |