Linux Audio

Check our new training course

Buildroot integration, development and maintenance

Need a Buildroot system for your embedded project?
Loading...
Note: File does not exist in v3.1.
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Simple kernel console driver for STM devices
 4 * Copyright (c) 2014, Intel Corporation.
 5 *
 6 * STM console will send kernel messages over STM devices to a trace host.
 7 */
 8
 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>
14
15static int stm_console_link(struct stm_source_data *data);
16static void stm_console_unlink(struct stm_source_data *data);
17
18static struct stm_console {
19	struct stm_source_data	data;
20	struct console		console;
21} stm_console = {
22	.data	= {
23		.name		= "console",
24		.nr_chans	= 1,
25		.type		= STM_USER,
26		.link		= stm_console_link,
27		.unlink		= stm_console_unlink,
28	},
29};
30
31static void
32stm_console_write(struct console *con, const char *buf, unsigned len)
33{
34	struct stm_console *sc = container_of(con, struct stm_console, console);
35
36	stm_source_write(&sc->data, 0, buf, len);
37}
38
39static int stm_console_link(struct stm_source_data *data)
40{
41	struct stm_console *sc = container_of(data, struct stm_console, data);
42
43	strcpy(sc->console.name, "stm_console");
44	sc->console.write = stm_console_write;
45	sc->console.flags = CON_ENABLED | CON_PRINTBUFFER;
46	register_console(&sc->console);
47
48	return 0;
49}
50
51static void stm_console_unlink(struct stm_source_data *data)
52{
53	struct stm_console *sc = container_of(data, struct stm_console, data);
54
55	unregister_console(&sc->console);
56}
57
58static int stm_console_init(void)
59{
60	return stm_source_register_device(NULL, &stm_console.data);
61}
62
63static void stm_console_exit(void)
64{
65	stm_source_unregister_device(&stm_console.data);
66}
67
68module_init(stm_console_init);
69module_exit(stm_console_exit);
70
71MODULE_LICENSE("GPL v2");
72MODULE_DESCRIPTION("stm_console driver");
73MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");