summaryrefslogtreecommitdiff
path: root/drivers/char/ttyprintk.c
diff options
context:
space:
mode:
authorVincent Whitchurch <vincent.whitchurch@axis.com>2022-02-15 15:17:49 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-22 16:24:47 +0200
commit7ea4aa70bfcec3225e2a38d8934c0b1f582c48c1 (patch)
treee687e6852fc5e1682d221eebc8e88c85c1d6b244 /drivers/char/ttyprintk.c
parent8f3631f0f6eb42e57f0ed120d105483c3ef61e49 (diff)
downloadlwn-7ea4aa70bfcec3225e2a38d8934c0b1f582c48c1.tar.gz
lwn-7ea4aa70bfcec3225e2a38d8934c0b1f582c48c1.zip
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: Vincent Whitchurch <vincent.whitchurch@axis.com> Link: https://lore.kernel.org/r/20220215141750.92808-1-vincent.whitchurch@axis.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char/ttyprintk.c')
-rw-r--r--drivers/char/ttyprintk.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index adf941c47506..ed45d04905c2 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -11,6 +11,7 @@
* of the boot process, for example.
*/
+#include <linux/console.h>
#include <linux/device.h>
#include <linux/serial.h>
#include <linux/tty.h>
@@ -163,6 +164,18 @@ static const struct tty_port_operations tpk_port_ops = {
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)
{
int ret;
@@ -195,6 +208,8 @@ static int __init ttyprintk_init(void)
goto error;
}
+ register_console(&ttyprintk_console);
+
return 0;
error:
@@ -205,6 +220,7 @@ error:
static void __exit ttyprintk_exit(void)
{
+ unregister_console(&ttyprintk_console);
tty_unregister_driver(ttyprintk_driver);
tty_driver_kref_put(ttyprintk_driver);
tty_port_destroy(&tpk_port.port);