aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-02-03 15:31:30 +0200
committerPetr Mladek <pmladek@suse.com>2020-02-11 10:44:22 +0100
commited31685c96e18f773ca11dd1a637974d62130673 (patch)
tree0cb9fcbf8d3ebb43a1382f6a2ed757547963e2b9
parente78bedbd42b7caa65551f3d56cbff451ccbd0aee (diff)
downloadprintk-for-5.7-console-exit.tar.gz
console: Introduce ->exit() callbackfor-5.7-console-exit
Some consoles might require special operations on unregistering. For instance, serial console, when registered in the kernel, keeps power on for entire time, until it gets unregistered. Example of use: ->setup(console): pm_runtime_get(...); ->exit(console): pm_runtime_put(...); For such cases to have a balance we would provide ->exit() callback. Link: http://lkml.kernel.org/r/20200203133130.11591-7-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> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com>
-rw-r--r--include/linux/console.h1
-rw-r--r--kernel/printk/printk.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/console.h b/include/linux/console.h
index d09951d5a94e4a..0cbd2a36aa0028 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -149,6 +149,7 @@ struct console {
struct tty_driver *(*device)(struct console *, int *);
void (*unblank)(void);
int (*setup)(struct console *, char *);
+ int (*exit)(struct console *);
int (*match)(struct console *, char *name, int idx, char *options);
short flags;
short index;
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f435a17ef98826..633f41a11d759c 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2853,6 +2853,9 @@ int unregister_console(struct console *console)
console_unlock();
console_sysfs_notify();
+ if (console->exit)
+ res = console->exit(console);
+
return res;
out_disable_unlock: