1 // SPDX-License-Identifier: GPL-2.0
3 * Simple kernel console driver for STM devices
4 * Copyright (c) 2014, Intel Corporation.
6 * STM console will send kernel messages over STM devices to a trace host.
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/console.h>
12 #include <linux/slab.h>
13 #include <linux/stm.h>
15 static int stm_console_link(struct stm_source_data *data);
16 static void stm_console_unlink(struct stm_source_data *data);
18 static struct stm_console {
19 struct stm_source_data data;
20 struct console console;
25 .link = stm_console_link,
26 .unlink = stm_console_unlink,
31 stm_console_write(struct console *con, const char *buf, unsigned len)
33 struct stm_console *sc = container_of(con, struct stm_console, console);
35 stm_source_write(&sc->data, 0, buf, len);
38 static int stm_console_link(struct stm_source_data *data)
40 struct stm_console *sc = container_of(data, struct stm_console, data);
42 strcpy(sc->console.name, "stm_console");
43 sc->console.write = stm_console_write;
44 sc->console.flags = CON_ENABLED | CON_PRINTBUFFER;
45 register_console(&sc->console);
50 static void stm_console_unlink(struct stm_source_data *data)
52 struct stm_console *sc = container_of(data, struct stm_console, data);
54 unregister_console(&sc->console);
57 static int stm_console_init(void)
59 return stm_source_register_device(NULL, &stm_console.data);
62 static void stm_console_exit(void)
64 stm_source_unregister_device(&stm_console.data);
67 module_init(stm_console_init);
68 module_exit(stm_console_exit);
70 MODULE_LICENSE("GPL v2");
71 MODULE_DESCRIPTION("stm_console driver");
72 MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");