Merge tag 'tty-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[sfrench/cifs-2.6.git] / kernel / printk / printk.c
index a000bef511772b4a10613d16c5ea135686f90033..ca5146006b94c6742ac770323aaf123688d65572 100644 (file)
@@ -3269,6 +3269,21 @@ static int __init keep_bootcon_setup(char *str)
 
 early_param("keep_bootcon", keep_bootcon_setup);
 
+static int console_call_setup(struct console *newcon, char *options)
+{
+       int err;
+
+       if (!newcon->setup)
+               return 0;
+
+       /* Synchronize with possible boot console. */
+       console_lock();
+       err = newcon->setup(newcon, options);
+       console_unlock();
+
+       return err;
+}
+
 /*
  * This is called by register_console() to try to match
  * the newly registered console with any of the ones selected
@@ -3304,8 +3319,8 @@ static int try_enable_preferred_console(struct console *newcon,
                        if (_braille_register_console(newcon, c))
                                return 0;
 
-                       if (newcon->setup &&
-                           (err = newcon->setup(newcon, c->options)) != 0)
+                       err = console_call_setup(newcon, c->options);
+                       if (err)
                                return err;
                }
                newcon->flags |= CON_ENABLED;
@@ -3331,7 +3346,7 @@ static void try_enable_default_console(struct console *newcon)
        if (newcon->index < 0)
                newcon->index = 0;
 
-       if (newcon->setup && newcon->setup(newcon, NULL) != 0)
+       if (console_call_setup(newcon, NULL) != 0)
                return;
 
        newcon->flags |= CON_ENABLED;