Skip to content

Commit

Permalink
console: Introduce ->exit() callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Petr Mladek committed Feb 11, 2020
1 parent e78bedb commit ed31685
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ed31685

Please sign in to comment.