Skip to contentSkip to conversation

serial: 8250_lpss: Extract dw8250_do_set_termios() for common use

PATCH In review Andy Shevchenko 2 participants 3 messages Oct 5, 2021 – Oct 6, 2021

Subsystems (3)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH v2 1/2 serial: 8250_lpss: Extract dw8250_do_set_termios() for common use

Some of the code currently used in dw8250_set_termios(), byt_set_termios() may be reused by other methods in the future. Extract it to a common helper function.

---
v2: split out unrelated change (Greg)

 drivers/tty/serial/8250/8250_dw.c    |  6 +-----
 drivers/tty/serial/8250/8250_dwlib.c | 10 ++++++++++
 drivers/tty/serial/8250/8250_dwlib.h |  1 +
 drivers/tty/serial/8250/8250_lpss.c  |  6 +-----
 4 files changed, 13 insertions(+), 10 deletions(-)
drivers/tty/serial/8250/8250_dw.c +1 -5
index a3a0154da567..d13c2e58f50f 100644
@@ -350,11 +350,7 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
 	}
 	clk_prepare_enable(d->clk);
 
-	p->status &= ~UPSTAT_AUTOCTS;
-	if (termios->c_cflag & CRTSCTS)
-		p->status |= UPSTAT_AUTOCTS;
-
-	serial8250_do_set_termios(p, termios, old);
+	dw8250_do_set_termios(p, termios, old);
 }
 
 static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
drivers/tty/serial/8250/8250_dwlib.c +10 -0
index 6d6a78eead3e..622d3b0d89e7 100644
@@ -77,6 +77,16 @@ static void dw8250_set_divisor(struct uart_port *p, unsigned int baud,
 	serial8250_do_set_divisor(p, baud, quot, quot_frac);
 }
 
+void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old)
+{
+	p->status &= ~UPSTAT_AUTOCTS;
+	if (termios->c_cflag & CRTSCTS)
+		p->status |= UPSTAT_AUTOCTS;
+
+	serial8250_do_set_termios(p, termios, old);
+}
+EXPORT_SYMBOL_GPL(dw8250_do_set_termios);
+
 void dw8250_setup_port(struct uart_port *p)
 {
 	struct uart_8250_port *up = up_to_u8250p(p);
drivers/tty/serial/8250/8250_dwlib.h +1 -0
index 9a12953832d3..83d528e5cc21 100644
@@ -16,4 +16,5 @@ struct dw8250_port_data {
 	u8			dlf_size;
 };
 
+void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old);
 void dw8250_setup_port(struct uart_port *p);
drivers/tty/serial/8250/8250_lpss.c +1 -5
index 848d81e3838c..398d2c4a40e3 100644
@@ -100,11 +100,7 @@ static void byt_set_termios(struct uart_port *p, struct ktermios *termios,
 	reg |= BYT_PRV_CLK_EN | BYT_PRV_CLK_UPDATE;
 	writel(reg, p->membase + BYT_PRV_CLK);
 
-	p->status &= ~UPSTAT_AUTOCTS;
-	if (termios->c_cflag & CRTSCTS)
-		p->status |= UPSTAT_AUTOCTS;
-
-	serial8250_do_set_termios(p, termios, old);
+	dw8250_do_set_termios(p, termios, old);
 }
 
 static unsigned int byt_get_mctrl(struct uart_port *port)
Signature · 1 line
2.33.0
author reviewer
#1 lore raw

PATCH v2 2/2 serial: 8250_lpss: Enable PSE UART Auto Flow Control

From: Aman Kumar <[email protected]>

Add a call to the custom ->set_termios() which has implementation about changing the state of RTS and CTS.

---
v2: no changes

 drivers/tty/serial/8250/8250_lpss.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +3 -0
index 398d2c4a40e3..d3bafec7619d 100644
@@ -164,6 +164,9 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
 	 * matching with the registered General Purpose DMA controllers.
 	 */
 	up->dma = dma;
+
+	port->set_termios = dw8250_do_set_termios;
+
 	return 0;
 }
 
Signature · 1 line
2.33.0
maintainer Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] serial: 8250_lpss: Enable PSE UART Auto Flow Control

Quoted 4 lines · Andy Shevchenko

From: Aman Kumar <[email protected]>

Add a call to the custom ->set_termios() which has implementation about changing the state of RTS and CTS.

Worth noting that:
config SERIAL_8250_LPSS
already does:
select SERIAL_8250_DWLIB

Quoted 22 lines

---
v2: no changes

  drivers/tty/serial/8250/8250_lpss.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +3 -0
index 398d2c4a40e3..d3bafec7619d 100644
@@ -164,6 +164,9 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)
  	 * matching with the registered General Purpose DMA controllers.
  	 */
  	up->dma = dma;
+
+	port->set_termios = dw8250_do_set_termios;
+
  	return 0;
  }
 
Signature · 2 lines
js
suse labs