Skip to content

Commit 49a8042

Browse files
l1kgregkh
authored andcommitted
serial: pl011: Drop redundant DTR/RTS preservation on close/open
Commit d8d8ffa ("amba-pl011: do not disable RTS during shutdown") amended the PL011 serial driver to leave DTR/RTS polarity untouched on tty close. That change made sense. But the commit also added code to save DTR/RTS state to an internal variable on tty close and restore it on tty open. That part of the commit makes less sense: The driver has no ->pm() callback, so the uart remains powered after tty close and automatically preserves register state, including DTR/RTS. Saving and restoring registers isn't the job of the ->startup() and ->shutdown() callbacks anyway. Rather, it should happen in ->pm(). Additionally, after pl011_startup() restores the state, the serial core overrides it in uart_port_dtr_rts() if a baud rate has been set: tty_port_open() uart_port_activate() uart_startup() uart_port_startup() pl011_startup() # restores DTR/RTS from uap->old_cr tty_port_block_til_ready() tty_port_raise_dtr_rts # if (C_BAUD(tty)) uart_dtr_rts() uart_port_dtr_rts() # raises DTR/RTS The serial core also overrides DTR/RTS on tty close in uart_shutdown() if C_HUPCL(tty) is set. So a user-defined DTR/RTS polarity won't survive a close/open cycle anyway, unless the user has set the baud rate to zero and disabled hupcl on the tty. Bottom line is, the code to save and restore DTR/RTS has no effect. Remove it. Cc: Linus Walleij <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: Lukas Wunner <[email protected]> Link: https://lore.kernel.org/r/e22089ab49e6e78822c50c8c4db46bf3ee885623.1641129328.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e368cc6 commit 49a8042

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/tty/serial/amba-pl011.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ struct uart_amba_port {
230230
unsigned int im; /* interrupt mask */
231231
unsigned int old_status;
232232
unsigned int fifosize; /* vendor-specific */
233-
unsigned int old_cr; /* state during shutdown */
234233
unsigned int fixed_baud; /* vendor-set fixed baud rate */
235234
char type[12];
236235
bool rs485_tx_started;
@@ -1805,8 +1804,8 @@ static int pl011_startup(struct uart_port *port)
18051804

18061805
spin_lock_irq(&uap->port.lock);
18071806

1808-
/* restore RTS and DTR */
1809-
cr = uap->old_cr & (UART011_CR_RTS | UART011_CR_DTR);
1807+
cr = pl011_read(uap, REG_CR);
1808+
cr &= UART011_CR_RTS | UART011_CR_DTR;
18101809
cr |= UART01x_CR_UARTEN | UART011_CR_RXE;
18111810

18121811
if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -1883,7 +1882,6 @@ static void pl011_disable_uart(struct uart_amba_port *uap)
18831882
uap->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS);
18841883
spin_lock_irq(&uap->port.lock);
18851884
cr = pl011_read(uap, REG_CR);
1886-
uap->old_cr = cr;
18871885
cr &= UART011_CR_RTS | UART011_CR_DTR;
18881886
cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
18891887
pl011_write(cr, uap, REG_CR);
@@ -2699,7 +2697,6 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
26992697

27002698
index = pl011_probe_dt_alias(index, dev);
27012699

2702-
uap->old_cr = 0;
27032700
uap->port.dev = dev;
27042701
uap->port.mapbase = mmiobase->start;
27052702
uap->port.membase = base;

0 commit comments

Comments
 (0)