diff options
author | 2020-02-03 15:31:28 +0200 | |
---|---|---|
committer | 2020-02-11 10:44:12 +0100 | |
commit | bb72e3981d8e7bb80db7cebc57a4e10769a509c9 (patch) | |
tree | d4e2a35e6c92d586f67efa6b23cedcb81e90d554 /kernel/printk | |
parent | console: Drop misleading comment (diff) | |
download | linux-bb72e3981d8e7bb80db7cebc57a4e10769a509c9.tar.gz linux-bb72e3981d8e7bb80db7cebc57a4e10769a509c9.tar.bz2 linux-bb72e3981d8e7bb80db7cebc57a4e10769a509c9.zip |
console: Avoid positive return code from unregister_console()
There are only two callers that use the returned code from
unregister_console():
- unregister_early_console() in arch/m68k/kernel/early_printk.c
- kgdb_unregister_nmi_console() in drivers/tty/serial/kgdb_nmi.c
They both expect to get "0" on success and a non-zero value on error.
But the current behavior is confusing and buggy:
- _braille_unregister_console() returns "1" on success
- unregister_console() returns "1" on error
Fix and clean up the behavior:
- Return success when _braille_unregister_console() succeeded
- Return a meaningful error code when the console was
not registered before
Link: http://lkml.kernel.org/r/20200203133130.11591-5-andriy.shevchenko@linux.intel.com
To: linux-kernel@vger.kernel.org
To: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk')
-rw-r--r-- | kernel/printk/printk.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index b0c12c08cac4..61d188f4c672 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2816,10 +2816,12 @@ int unregister_console(struct console *console) console->name, console->index); res = _braille_unregister_console(console); - if (res) + if (res < 0) return res; + if (res > 0) + return 0; - res = 1; + res = -ENODEV; console_lock(); if (console_drivers == console) { console_drivers=console->next; |