[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241025105728.602310-4-john.ogness@linutronix.de>
Date: Fri, 25 Oct 2024 13:03:25 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Jiri Slaby <jirislaby@...nel.org>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
Esben Haabendal <esben@...nix.com>,
linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rengarajan S <rengarajan.s@...rochip.com>,
Peter Collingbourne <pcc@...gle.com>,
Serge Semin <fancer.lancer@...il.com>,
Lino Sanfilippo <l.sanfilippo@...bus.com>
Subject: [PATCH tty-next v3 3/6] serial: 8250: Split out rx stop/start code into helpers
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@...utronix.de>
---
drivers/tty/serial/8250/8250_port.c | 37 ++++++++++++++++++++---------
1 file changed, 26 insertions(+), 11 deletions(-)
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);
--
2.39.5
Powered by blists - more mailing lists