Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vincent Whitchurch and committed by
Greg Kroah-Hartman
7ea4aa70 8f3631f0

+18 -1
+2 -1
drivers/char/Kconfig
··· 18 18 The feature is useful to inline user messages with kernel 19 19 messages. 20 20 In order to use this feature, you should output user messages 21 - to /dev/ttyprintk or redirect console to this TTY. 21 + to /dev/ttyprintk or redirect console to this TTY, or boot 22 + the kernel with console=ttyprintk. 22 23 23 24 If unsure, say N. 24 25
+16
drivers/char/ttyprintk.c
··· 11 11 * of the boot process, for example. 12 12 */ 13 13 14 + #include <linux/console.h> 14 15 #include <linux/device.h> 15 16 #include <linux/serial.h> 16 17 #include <linux/tty.h> ··· 164 163 165 164 static struct tty_driver *ttyprintk_driver; 166 165 166 + static struct tty_driver *ttyprintk_console_device(struct console *c, 167 + int *index) 168 + { 169 + *index = 0; 170 + return ttyprintk_driver; 171 + } 172 + 173 + static struct console ttyprintk_console = { 174 + .name = "ttyprintk", 175 + .device = ttyprintk_console_device, 176 + }; 177 + 167 178 static int __init ttyprintk_init(void) 168 179 { 169 180 int ret; ··· 208 195 goto error; 209 196 } 210 197 198 + register_console(&ttyprintk_console); 199 + 211 200 return 0; 212 201 213 202 error: ··· 220 205 221 206 static void __exit ttyprintk_exit(void) 222 207 { 208 + unregister_console(&ttyprintk_console); 223 209 tty_unregister_driver(ttyprintk_driver); 224 210 tty_driver_kref_put(ttyprintk_driver); 225 211 tty_port_destroy(&tpk_port.port);