tty: serial: do unlock on a common path in altera_jtaguart_console_putc()
authorJiri Slaby <jslaby@suse.cz>
Tue, 27 Sep 2022 11:18:19 +0000 (13:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Sep 2022 12:58:46 +0000 (14:58 +0200)
port->lock is unlocked in each branch in altera_jtaguart_console_putc(),
so do it before the "if". "status" needs not be under the lock, as the
register was already read.

Cc: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Tobias Klauser <tklauser@distanz.ch>
Link: https://lore.kernel.org/r/20220927111819.18516-4-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/altera_jtaguart.c

index ac8ce418de36d606e7a9cb57a9ed5031607369e5..c2d154d78e545904a3a6ac9c2d5ede39dda9be6e 100644 (file)
@@ -310,11 +310,12 @@ static void altera_jtaguart_console_putc(struct uart_port *port, unsigned char c
 
        spin_lock_irqsave(&port->lock, flags);
        while (!altera_jtaguart_tx_space(port, &status)) {
+               spin_unlock_irqrestore(&port->lock, flags);
+
                if ((status & ALTERA_JTAGUART_CONTROL_AC_MSK) == 0) {
-                       spin_unlock_irqrestore(&port->lock, flags);
                        return; /* no connection activity */
                }
-               spin_unlock_irqrestore(&port->lock, flags);
+
                cpu_relax();
                spin_lock_irqsave(&port->lock, flags);
        }