diff options
author | Lukas Wunner <lukas@wunner.de> | 2017-11-24 17:26:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-28 10:05:20 -0500 |
commit | 01d845352a81df133234a106f34cc93937dcb7bd (patch) | |
tree | ddd7f1e26988c832c090e3f0323429c44c56eda4 | |
parent | f1e5b618c1c26cb8b5818e36f996e8c2fbedbeb7 (diff) |
serial: fsl_lpuart: Support common rs485 binding for RTS polarity
Invoke the ->rs485_config callback on probe to set UARTMODEM_TXRTSPOL
appropriately based on the UART's device properties.
This implicitly sets UARTMODEM_TXRTSE if rs485 was enabled in the device
properties, so drop the identical code from lpuart_probe().
It also fixes a bug: If an unsupported rs485 property was specified
(rs485-rx-during-tx or rs485-rts-delay), the driver returns -ENOSYS
without performing any cleanup, in particular without calling
uart_remove_one_port() or clk_disable_unprepare(), thus leaking the
uart_port. But with the invocation of ->rs485_config, the unsupported
properties are now cleared in struct serial_rs485 and thus ignored.
It therefore seems sufficient to just log an error instead of bailing
out.
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/fsl_lpuart.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 38e76f95490e..8cf112f2efc3 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c | |||
@@ -2208,21 +2208,14 @@ static int lpuart_probe(struct platform_device *pdev) | |||
2208 | 2208 | ||
2209 | uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); | 2209 | uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); |
2210 | 2210 | ||
2211 | if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) { | 2211 | if (sport->port.rs485.flags & SER_RS485_RX_DURING_TX) |
2212 | dev_err(&pdev->dev, "driver doesn't support RX during TX\n"); | 2212 | dev_err(&pdev->dev, "driver doesn't support RX during TX\n"); |
2213 | return -ENOSYS; | ||
2214 | } | ||
2215 | 2213 | ||
2216 | if (sport->port.rs485.delay_rts_before_send || | 2214 | if (sport->port.rs485.delay_rts_before_send || |
2217 | sport->port.rs485.delay_rts_after_send) { | 2215 | sport->port.rs485.delay_rts_after_send) |
2218 | dev_err(&pdev->dev, "driver doesn't support RTS delays\n"); | 2216 | dev_err(&pdev->dev, "driver doesn't support RTS delays\n"); |
2219 | return -ENOSYS; | ||
2220 | } | ||
2221 | 2217 | ||
2222 | if (sport->port.rs485.flags & SER_RS485_ENABLED) { | 2218 | lpuart_config_rs485(&sport->port, &sport->port.rs485); |
2223 | sport->port.rs485.flags |= SER_RS485_RTS_ON_SEND; | ||
2224 | writeb(UARTMODEM_TXRTSE, sport->port.membase + UARTMODEM); | ||
2225 | } | ||
2226 | 2219 | ||
2227 | sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx"); | 2220 | sport->dma_tx_chan = dma_request_slave_channel(sport->port.dev, "tx"); |
2228 | if (!sport->dma_tx_chan) | 2221 | if (!sport->dma_tx_chan) |