Commit 5f3a4813 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'for-5.7-console-exit' of...

Merge branch 'for-5.7-console-exit' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk into tty-next

We need the console patches in here as well for futher work from Andy.

* 'for-5.7-console-exit' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk:
  console: Introduce ->exit() callback
  console: Don't notify user space when unregister non-listed console
  console: Avoid positive return code from unregister_console()
  console: Drop misleading comment
  console: Use for_each_console() helper in unregister_console()
  console: Drop double check for console_drivers being non-NULL
  console: Don't perform test for CON_BRL flag
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parents 7e13d0a6 ed31685c
...@@ -347,8 +347,6 @@ int braille_register_console(struct console *console, int index, ...@@ -347,8 +347,6 @@ int braille_register_console(struct console *console, int index,
{ {
int ret; int ret;
if (!(console->flags & CON_BRL))
return 0;
if (!console_options) if (!console_options)
/* Only support VisioBraille for now */ /* Only support VisioBraille for now */
console_options = "57600o8"; console_options = "57600o8";
...@@ -371,8 +369,6 @@ int braille_unregister_console(struct console *console) ...@@ -371,8 +369,6 @@ int braille_unregister_console(struct console *console)
{ {
if (braille_co != console) if (braille_co != console)
return -EINVAL; return -EINVAL;
if (!(console->flags & CON_BRL))
return 0;
unregister_keyboard_notifier(&keyboard_notifier_block); unregister_keyboard_notifier(&keyboard_notifier_block);
unregister_vt_notifier(&vt_notifier_block); unregister_vt_notifier(&vt_notifier_block);
braille_co = NULL; braille_co = NULL;
......
...@@ -148,6 +148,7 @@ struct console { ...@@ -148,6 +148,7 @@ struct console {
struct tty_driver *(*device)(struct console *, int *); struct tty_driver *(*device)(struct console *, int *);
void (*unblank)(void); void (*unblank)(void);
int (*setup)(struct console *, char *); int (*setup)(struct console *, char *);
int (*exit)(struct console *);
int (*match)(struct console *, char *name, int idx, char *options); int (*match)(struct console *, char *name, int idx, char *options);
short flags; short flags;
short index; short index;
......
...@@ -1772,9 +1772,6 @@ static void call_console_drivers(const char *ext_text, size_t ext_len, ...@@ -1772,9 +1772,6 @@ static void call_console_drivers(const char *ext_text, size_t ext_len,
trace_console_rcuidle(text, len); trace_console_rcuidle(text, len);
if (!console_drivers)
return;
for_each_console(con) { for_each_console(con) {
if (exclusive_console && con != exclusive_console) if (exclusive_console && con != exclusive_console)
continue; continue;
...@@ -2653,19 +2650,17 @@ void register_console(struct console *newcon) ...@@ -2653,19 +2650,17 @@ void register_console(struct console *newcon)
struct console_cmdline *c; struct console_cmdline *c;
static bool has_preferred; static bool has_preferred;
if (console_drivers) for_each_console(bcon) {
for_each_console(bcon) if (WARN(bcon == newcon, "console '%s%d' already registered\n",
if (WARN(bcon == newcon, bcon->name, bcon->index))
"console '%s%d' already registered\n", return;
bcon->name, bcon->index)) }
return;
/* /*
* before we register a new CON_BOOT console, make sure we don't * before we register a new CON_BOOT console, make sure we don't
* already have a valid console * already have a valid console
*/ */
if (console_drivers && newcon->flags & CON_BOOT) { if (newcon->flags & CON_BOOT) {
/* find the last or real console */
for_each_console(bcon) { for_each_console(bcon) {
if (!(bcon->flags & CON_BOOT)) { if (!(bcon->flags & CON_BOOT)) {
pr_info("Too late to register bootconsole %s%d\n", pr_info("Too late to register bootconsole %s%d\n",
...@@ -2813,7 +2808,7 @@ EXPORT_SYMBOL(register_console); ...@@ -2813,7 +2808,7 @@ EXPORT_SYMBOL(register_console);
int unregister_console(struct console *console) int unregister_console(struct console *console)
{ {
struct console *a, *b; struct console *con;
int res; int res;
pr_info("%sconsole [%s%d] disabled\n", pr_info("%sconsole [%s%d] disabled\n",
...@@ -2821,26 +2816,30 @@ int unregister_console(struct console *console) ...@@ -2821,26 +2816,30 @@ int unregister_console(struct console *console)
console->name, console->index); console->name, console->index);
res = _braille_unregister_console(console); res = _braille_unregister_console(console);
if (res) if (res < 0)
return res; return res;
if (res > 0)
return 0;
res = 1; res = -ENODEV;
console_lock(); console_lock();
if (console_drivers == console) { if (console_drivers == console) {
console_drivers=console->next; console_drivers=console->next;
res = 0; res = 0;
} else if (console_drivers) { } else {
for (a=console_drivers->next, b=console_drivers ; for_each_console(con) {
a; b=a, a=b->next) { if (con->next == console) {
if (a == console) { con->next = console->next;
b->next = a->next;
res = 0; res = 0;
break; break;
} }
} }
} }
if (!res && (console->flags & CON_EXTENDED)) if (res)
goto out_disable_unlock;
if (console->flags & CON_EXTENDED)
nr_ext_console_drivers--; nr_ext_console_drivers--;
/* /*
...@@ -2853,6 +2852,16 @@ int unregister_console(struct console *console) ...@@ -2853,6 +2852,16 @@ int unregister_console(struct console *console)
console->flags &= ~CON_ENABLED; console->flags &= ~CON_ENABLED;
console_unlock(); console_unlock();
console_sysfs_notify(); console_sysfs_notify();
if (console->exit)
res = console->exit(console);
return res;
out_disable_unlock:
console->flags &= ~CON_ENABLED;
console_unlock();
return res; return res;
} }
EXPORT_SYMBOL(unregister_console); EXPORT_SYMBOL(unregister_console);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment