Commit 7ea4aa70 authored by Vincent Whitchurch's avatar Vincent Whitchurch Committed by Greg Kroah-Hartman

char: ttyprintk: register console

Register a console in the ttyprintk driver so that it can be selected
for /dev/console with console=ttyprintk on the kernel command line,
similar to other console drivers.
Signed-off-by: default avatarVincent Whitchurch <vincent.whitchurch@axis.com>
Link: https://lore.kernel.org/r/20220215141750.92808-1-vincent.whitchurch@axis.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8f3631f0
...@@ -18,7 +18,8 @@ config TTY_PRINTK ...@@ -18,7 +18,8 @@ config TTY_PRINTK
The feature is useful to inline user messages with kernel The feature is useful to inline user messages with kernel
messages. messages.
In order to use this feature, you should output user messages In order to use this feature, you should output user messages
to /dev/ttyprintk or redirect console to this TTY. to /dev/ttyprintk or redirect console to this TTY, or boot
the kernel with console=ttyprintk.
If unsure, say N. If unsure, say N.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* of the boot process, for example. * of the boot process, for example.
*/ */
#include <linux/console.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/serial.h> #include <linux/serial.h>
#include <linux/tty.h> #include <linux/tty.h>
...@@ -163,6 +164,18 @@ static const struct tty_port_operations tpk_port_ops = { ...@@ -163,6 +164,18 @@ static const struct tty_port_operations tpk_port_ops = {
static struct tty_driver *ttyprintk_driver; static struct tty_driver *ttyprintk_driver;
static struct tty_driver *ttyprintk_console_device(struct console *c,
int *index)
{
*index = 0;
return ttyprintk_driver;
}
static struct console ttyprintk_console = {
.name = "ttyprintk",
.device = ttyprintk_console_device,
};
static int __init ttyprintk_init(void) static int __init ttyprintk_init(void)
{ {
int ret; int ret;
...@@ -195,6 +208,8 @@ static int __init ttyprintk_init(void) ...@@ -195,6 +208,8 @@ static int __init ttyprintk_init(void)
goto error; goto error;
} }
register_console(&ttyprintk_console);
return 0; return 0;
error: error:
...@@ -205,6 +220,7 @@ static int __init ttyprintk_init(void) ...@@ -205,6 +220,7 @@ static int __init ttyprintk_init(void)
static void __exit ttyprintk_exit(void) static void __exit ttyprintk_exit(void)
{ {
unregister_console(&ttyprintk_console);
tty_unregister_driver(ttyprintk_driver); tty_unregister_driver(ttyprintk_driver);
tty_driver_kref_put(ttyprintk_driver); tty_driver_kref_put(ttyprintk_driver);
tty_port_destroy(&tpk_port.port); tty_port_destroy(&tpk_port.port);
......
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