diff mbox series

[tty-next,v3,3/6] serial: 8250: Split out rx stop/start code into helpers

Message ID 20241025105728.602310-4-john.ogness@linutronix.de
State New
Headers show
Series convert 8250 to nbcon | expand

Commit Message

John Ogness Oct. 25, 2024, 10:57 a.m. UTC
The rx stop/start callbacks also disable/enable interrupts. This
is not acceptable for the console write callback since it must
manage all interrupt disabling/enabling.

Move the interrupt disabling/enabling/masking into helper
functions so that the console write callback can make use of
the appropriate parts in a follow-up commit.

This is essentially refactoring and should cause no functional
change.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/tty/serial/8250/8250_port.c | 37 ++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 11 deletions(-)

Comments

Andy Shevchenko Oct. 25, 2024, 1:55 p.m. UTC | #1
On Fri, Oct 25, 2024 at 01:03:25PM +0206, John Ogness wrote:
> The rx stop/start callbacks also disable/enable interrupts. This

disable/enable --> toggle ?

> is not acceptable for the console write callback since it must
> manage all interrupt disabling/enabling.

toggling ?

> Move the interrupt disabling/enabling/masking into helper

toggling and masking ?

> functions so that the console write callback can make use of
> the appropriate parts in a follow-up commit.
> 
> This is essentially refactoring and should cause no functional
> change.

Please, be consistent in the commit messages on how you apply terms Rx and Tx
(or TX and RX, but I think the former is more usual WRT UART). This applies
to the whole series.

Code wise looks fine to me
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Petr Mladek Nov. 6, 2024, 10:54 a.m. UTC | #2
On Fri 2024-10-25 13:03:25, John Ogness wrote:
> The rx stop/start callbacks also disable/enable interrupts. This
> is not acceptable for the console write callback since it must
> manage all interrupt disabling/enabling.
> 
> Move the interrupt disabling/enabling/masking into helper
> functions so that the console write callback can make use of
> the appropriate parts in a follow-up commit.
> 
> This is essentially refactoring and should cause no functional
> change.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

The changes look reasonable and do what described:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 8f7c9968ad41..09ac521d232a 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1360,18 +1360,37 @@  static void autoconfig_irq(struct uart_8250_port *up)
 	port->irq = (irq > 0) ? irq : 0;
 }
 
-static void serial8250_stop_rx(struct uart_port *port)
+static void __serial8250_stop_rx_mask_dr(struct uart_port *port)
 {
-	struct uart_8250_port *up = up_to_u8250p(port);
+	port->read_status_mask &= ~UART_LSR_DR;
+}
 
+static void __serial8250_stop_rx_int(struct uart_8250_port *p)
+{
 	/* Port locked to synchronize UART_IER access against the console. */
-	lockdep_assert_held_once(&port->lock);
+	lockdep_assert_held_once(&p->port.lock);
+
+	p->ier &= ~(UART_IER_RLSI | UART_IER_RDI);
+	serial_port_out(&p->port, UART_IER, p->ier);
+}
+
+static void __serial8250_start_rx_int(struct uart_8250_port *p)
+{
+	/* Port locked to synchronize UART_IER access against the console. */
+	lockdep_assert_held_once(&p->port.lock);
+
+	p->ier |= UART_IER_RLSI | UART_IER_RDI;
+	serial_port_out(&p->port, UART_IER, p->ier);
+}
+
+static void serial8250_stop_rx(struct uart_port *port)
+{
+	struct uart_8250_port *up = up_to_u8250p(port);
 
 	serial8250_rpm_get(up);
 
-	up->ier &= ~(UART_IER_RLSI | UART_IER_RDI);
-	up->port.read_status_mask &= ~UART_LSR_DR;
-	serial_port_out(port, UART_IER, up->ier);
+	__serial8250_stop_rx_mask_dr(port);
+	__serial8250_stop_rx_int(up);
 
 	serial8250_rpm_put(up);
 }
@@ -1386,9 +1405,6 @@  void serial8250_em485_stop_tx(struct uart_8250_port *p)
 {
 	unsigned char mcr = serial8250_in_MCR(p);
 
-	/* Port locked to synchronize UART_IER access against the console. */
-	lockdep_assert_held_once(&p->port.lock);
-
 	if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND)
 		mcr |= UART_MCR_RTS;
 	else
@@ -1403,8 +1419,7 @@  void serial8250_em485_stop_tx(struct uart_8250_port *p)
 	if (!(p->port.rs485.flags & SER_RS485_RX_DURING_TX)) {
 		serial8250_clear_and_reinit_fifos(p);
 
-		p->ier |= UART_IER_RLSI | UART_IER_RDI;
-		serial_port_out(&p->port, UART_IER, p->ier);
+		__serial8250_start_rx_int(p);
 	}
 }
 EXPORT_SYMBOL_GPL(serial8250_em485_stop_tx);