]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mxser: use tty_port_tty guard() in mxser_port_isr()
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Thu, 14 Aug 2025 07:24:46 +0000 (09:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Aug 2025 10:46:26 +0000 (12:46 +0200)
Use scoped_guard() and reorder the function. This is done separately
from the other changes, as it is slighly more intrusive: scoped_guard()
handles the have-tty case and returns. The non-tty case is done at the
end of the function.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250814072456.182853-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/mxser.c

index 2fc13cc02cc51b04081553be19479556bd244cf5..b070ebf9f51a180e7be4d8141423e225b57ae28e 100644 (file)
@@ -1600,54 +1600,50 @@ static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port
 
 static bool mxser_port_isr(struct mxser_port *port)
 {
-       struct tty_struct *tty;
        u8 iir, status;
-       bool error = false;
 
        iir = inb(port->ioaddr + UART_IIR);
        if (iir & UART_IIR_NO_INT)
                return true;
 
        iir &= MOXA_MUST_IIR_MASK;
-       tty = tty_port_tty_get(&port->port);
-       if (!tty) {
-               status = inb(port->ioaddr + UART_LSR);
-               outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
-                               port->ioaddr + UART_FCR);
-               inb(port->ioaddr + UART_MSR);
 
-               error = true;
-               goto put_tty;
-       }
+       scoped_guard(tty_port_tty, &port->port) {
+               struct tty_struct *tty = scoped_tty();
 
-       status = inb(port->ioaddr + UART_LSR);
+               status = inb(port->ioaddr + UART_LSR);
 
-       if (port->board->must_hwid) {
-               if (iir == MOXA_MUST_IIR_GDA ||
-                   iir == MOXA_MUST_IIR_RDA ||
-                   iir == MOXA_MUST_IIR_RTO ||
-                   iir == MOXA_MUST_IIR_LSR)
-                       status = mxser_receive_chars(tty, port, status);
-       } else {
-               status &= port->read_status_mask;
-               if (status & UART_LSR_DR)
-                       status = mxser_receive_chars(tty, port, status);
-       }
+               if (port->board->must_hwid) {
+                       if (iir == MOXA_MUST_IIR_GDA ||
+                           iir == MOXA_MUST_IIR_RDA ||
+                           iir == MOXA_MUST_IIR_RTO ||
+                           iir == MOXA_MUST_IIR_LSR)
+                               status = mxser_receive_chars(tty, port, status);
+               } else {
+                       status &= port->read_status_mask;
+                       if (status & UART_LSR_DR)
+                               status = mxser_receive_chars(tty, port, status);
+               }
 
-       mxser_check_modem_status(tty, port);
+               mxser_check_modem_status(tty, port);
 
-       if (port->board->must_hwid) {
-               if (iir == 0x02 && (status & UART_LSR_THRE))
-                       mxser_transmit_chars(tty, port);
-       } else {
-               if (status & UART_LSR_THRE)
-                       mxser_transmit_chars(tty, port);
+               if (port->board->must_hwid) {
+                       if (iir == 0x02 && (status & UART_LSR_THRE))
+                               mxser_transmit_chars(tty, port);
+               } else {
+                       if (status & UART_LSR_THRE)
+                               mxser_transmit_chars(tty, port);
+               }
+
+               return false;
        }
 
-put_tty:
-       tty_kref_put(tty);
+       status = inb(port->ioaddr + UART_LSR);
+       outb(port->FCR | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
+                       port->ioaddr + UART_FCR);
+       inb(port->ioaddr + UART_MSR);
 
-       return error;
+       return true;
 }
 
 /*