]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
serial: core: Introduce uart_console_enabled() helper
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 14 Feb 2020 11:43:32 +0000 (13:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 16:34:18 +0000 (08:34 -0800)
Introduce uart_console_enabled() helper which checks port to be console
and console is registered in the list.

Note, this helper will be used in the future as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200214114339.53897-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c

index 76e506ee335cebfc21a3490a5f29ae83bca4b0b6..d956da0b6d9cbd41d5768cc74f758767e609ccce 100644 (file)
@@ -1908,6 +1908,11 @@ static int uart_proc_show(struct seq_file *m, void *v)
 }
 #endif
 
+static inline bool uart_console_enabled(struct uart_port *port)
+{
+       return uart_console(port) && (port->cons->flags & CON_ENABLED);
+}
+
 #if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
 /**
  *     uart_console_write - write a console message to a serial port
@@ -2066,7 +2071,7 @@ uart_set_options(struct uart_port *port, struct console *co,
         * If this port is a console, then the spinlock is already
         * initialised.
         */
-       if (!(uart_console(port) && (port->cons->flags & CON_ENABLED))) {
+       if (!uart_console_enabled(port)) {
                spin_lock_init(&port->lock);
                lockdep_set_class(&port->lock, &port_lock_key);
        }
@@ -2828,7 +2833,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
         * If this port is a console, then the spinlock is already
         * initialised.
         */
-       if (!(uart_console(uport) && (uport->cons->flags & CON_ENABLED))) {
+       if (!uart_console_enabled(uport)) {
                spin_lock_init(&uport->lock);
                lockdep_set_class(&uport->lock, &port_lock_key);
        }