-From 9223be8453b362b46aff91a9d0f140f9c8b4e3d5 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From 3cc16ae096f164ae0c6b98416c25a01db5f3a529 Mon Sep 17 00:00:00 2001
+From: Sherry Sun <sherry.sun@nxp.com>
Date: Wed, 12 Mar 2025 10:39:03 +0800
Subject: tty: serial: fsl_lpuart: use port struct directly to simply code
From: Sherry Sun <sherry.sun@nxp.com>
-[ Upstream commit 3cc16ae096f164ae0c6b98416c25a01db5f3a529 ]
+commit 3cc16ae096f164ae0c6b98416c25a01db5f3a529 upstream.
Most lpuart functions have the parameter struct uart_port *port, but
still use the &sport->port to get the uart_port instead of use it
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Link: https://lore.kernel.org/r/20250312023904.1343351-3-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: e98ab45ec518 ("tty: serial: lpuart: only disable CTS instead of overwriting the whole UARTMODIR register")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- drivers/tty/serial/fsl_lpuart.c | 213 +++++++++++++++-----------------
- 1 file changed, 102 insertions(+), 111 deletions(-)
+ drivers/tty/serial/fsl_lpuart.c | 210 +++++++++++++++++++---------------------
+ 1 file changed, 102 insertions(+), 108 deletions(-)
-diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
-index 1afcfc40079d5..2971de64f6a3d 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
-@@ -581,7 +581,7 @@ static int lpuart_dma_tx_request(struct uart_port *port)
+@@ -581,7 +581,7 @@ static int lpuart_dma_tx_request(struct
ret = dmaengine_slave_config(sport->dma_tx_chan, &dma_tx_sconfig);
if (ret) {
"DMA slave config failed, err = %d\n", ret);
return ret;
}
-@@ -611,13 +611,13 @@ static void lpuart_flush_buffer(struct uart_port *port)
+@@ -611,13 +611,13 @@ static void lpuart_flush_buffer(struct u
}
if (lpuart_is_32(sport)) {
}
}
-@@ -639,38 +639,36 @@ static void lpuart32_wait_bit_set(struct uart_port *port, unsigned int offset,
-
- static int lpuart_poll_init(struct uart_port *port)
- {
-- struct lpuart_port *sport = container_of(port,
-- struct lpuart_port, port);
+@@ -644,33 +644,33 @@ static int lpuart_poll_init(struct uart_
unsigned long flags;
u8 temp;
return 0;
}
-@@ -693,33 +691,32 @@ static int lpuart_poll_get_char(struct uart_port *port)
- static int lpuart32_poll_init(struct uart_port *port)
- {
- unsigned long flags;
-- struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
+@@ -696,30 +696,30 @@ static int lpuart32_poll_init(struct uar
+ struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
u32 temp;
- sport->port.fifosize = 0;
return 0;
}
-@@ -1449,12 +1446,9 @@ static void lpuart_dma_rx_free(struct uart_port *port)
+@@ -1449,12 +1449,9 @@ static void lpuart_dma_rx_free(struct ua
static int lpuart_config_rs485(struct uart_port *port, struct ktermios *termios,
struct serial_rs485 *rs485)
{
if (rs485->flags & SER_RS485_ENABLED) {
/* Enable auto RS-485 RTS mode */
-@@ -1472,32 +1466,29 @@ static int lpuart_config_rs485(struct uart_port *port, struct ktermios *termios,
+@@ -1472,32 +1469,29 @@ static int lpuart_config_rs485(struct ua
modem &= ~UARTMODEM_TXRTSPOL;
}
if (rs485->flags & SER_RS485_ENABLED) {
/* Enable auto RS-485 RTS mode */
-@@ -1515,10 +1506,10 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio
+@@ -1515,10 +1509,10 @@ static int lpuart32_config_rs485(struct
modem &= ~UARTMODIR_TXRTSPOL;
}
return 0;
}
-@@ -1829,11 +1820,11 @@ static int lpuart_startup(struct uart_port *port)
+@@ -1829,11 +1823,11 @@ static int lpuart_startup(struct uart_po
u8 temp;
/* determine FIFO size and enable FIFO mode */
sport->rxfifo_size = UARTFIFO_DEPTH((temp >> UARTPFIFO_RXSIZE_OFF) &
UARTPFIFO_FIFOSIZE_MASK);
-@@ -1889,11 +1880,11 @@ static int lpuart32_startup(struct uart_port *port)
+@@ -1889,11 +1883,11 @@ static int lpuart32_startup(struct uart_
u32 temp;
/* determine FIFO size */
sport->rxfifo_size = UARTFIFO_DEPTH((temp >> UARTFIFO_RXSIZE_OFF) &
UARTFIFO_FIFOSIZE_MASK);
-@@ -1906,7 +1897,7 @@ static int lpuart32_startup(struct uart_port *port)
+@@ -1906,7 +1900,7 @@ static int lpuart32_startup(struct uart_
if (is_layerscape_lpuart(sport)) {
sport->rxfifo_size = 16;
sport->txfifo_size = 16;
}
lpuart_request_dma(sport);
-@@ -1966,8 +1957,8 @@ static void lpuart32_shutdown(struct uart_port *port)
+@@ -1966,8 +1960,8 @@ static void lpuart32_shutdown(struct uar
uart_port_lock_irqsave(port, &flags);
/* clear status */
/* disable Rx/Tx DMA */
temp = lpuart32_read(port, UARTBAUD);
-@@ -1996,12 +1987,12 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -1996,12 +1990,12 @@ lpuart_set_termios(struct uart_port *por
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
unsigned int sbr, brfa;
/*
* only support CS8 and CS7, and for CS7 must enable PE.
* supported mode:
-@@ -2033,7 +2024,7 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2033,7 +2027,7 @@ lpuart_set_termios(struct uart_port *por
* When auto RS-485 RTS mode is enabled,
* hardware flow control need to be disabled.
*/
termios->c_cflag &= ~CRTSCTS;
if (termios->c_cflag & CRTSCTS)
-@@ -2074,59 +2065,59 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2074,59 +2068,59 @@ lpuart_set_termios(struct uart_port *por
* Need to update the Ring buffer length according to the selected
* baud rate and restart Rx DMA path.
*
if (old && sport->lpuart_dma_rx_use) {
if (!lpuart_start_rx_dma(sport))
-@@ -2135,7 +2126,7 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2135,7 +2129,7 @@ lpuart_set_termios(struct uart_port *por
sport->lpuart_dma_rx_use = false;
}
}
static void __lpuart32_serial_setbrg(struct uart_port *port,
-@@ -2233,9 +2224,9 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2233,9 +2227,9 @@ lpuart32_set_termios(struct uart_port *p
unsigned int baud;
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
sport->is_cs7 = false;
/*
* only support CS8 and CS7
-@@ -2269,7 +2260,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2269,7 +2263,7 @@ lpuart32_set_termios(struct uart_port *p
* When auto RS-485 RTS mode is enabled,
* hardware flow control need to be disabled.
*/
termios->c_cflag &= ~CRTSCTS;
if (termios->c_cflag & CRTSCTS)
-@@ -2319,32 +2310,32 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2319,32 +2313,32 @@ lpuart32_set_termios(struct uart_port *p
* Need to update the Ring buffer length according to the selected
* baud rate and restart Rx DMA path.
*
}
/* update the per-port timeout */
-@@ -2356,22 +2347,22 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2356,22 +2350,22 @@ lpuart32_set_termios(struct uart_port *p
* asserted.
*/
if (!(old_ctrl & UARTCTRL_SBK)) {
if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE)
sport->is_cs7 = true;
-@@ -2383,7 +2374,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
+@@ -2383,7 +2377,7 @@ lpuart32_set_termios(struct uart_port *p
sport->lpuart_dma_rx_use = false;
}
}
static const char *lpuart_type(struct uart_port *port)
-@@ -2821,7 +2812,7 @@ static int lpuart_global_reset(struct lpuart_port *sport)
+@@ -2821,7 +2815,7 @@ static int lpuart_global_reset(struct lp
ret = clk_prepare_enable(sport->ipg_clk);
if (ret) {
return ret;
}
-@@ -2832,10 +2823,10 @@ static int lpuart_global_reset(struct lpuart_port *sport)
+@@ -2832,10 +2826,10 @@ static int lpuart_global_reset(struct lp
*/
ctrl = lpuart32_read(port, UARTCTRL);
if (ctrl & UARTCTRL_TE) {
"timeout waiting for transmit engine to complete\n");
clk_disable_unprepare(sport->ipg_clk);
return 0;
-@@ -3187,7 +3178,7 @@ static void lpuart_console_fixup(struct lpuart_port *sport)
+@@ -3187,7 +3181,7 @@ static void lpuart_console_fixup(struct
* in VLLS mode, or restore console setting here.
*/
if (is_imx7ulp_lpuart(sport) && lpuart_uport_is_active(sport) &&
mutex_lock(&port->mutex);
memset(&termios, 0, sizeof(struct ktermios));
---
-2.39.5
-