console: Introduce ->exit() callback
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 3 Feb 2020 13:31:30 +0000 (15:31 +0200)
committerPetr Mladek <pmladek@suse.com>
Tue, 11 Feb 2020 09:44:22 +0000 (10:44 +0100)
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>
include/linux/console.h
kernel/printk/printk.c

index d09951d5a94e4aa6341086aa98e186af8f10ba8f..0cbd2a36aa00281c957faf74a26ec82ed3db9d2d 100644 (file)
@@ -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;
index f435a17ef988260e1eb630b8bd3dde844b4027b9..633f41a11d759c29adcabf3d9c4381a41c05d9ba 100644 (file)
@@ -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: