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

stm class: stm_console: Add kernel-console-over-stm driver

This is a simple stm_source class device driver (kernelspace stm trace
source) that registers a console and sends kernel messages over STM
devices.

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Shishkin and committed by
Greg Kroah-Hartman
e3e5a3d3 2c415381

+93
+9
drivers/hwtracing/stm/Kconfig
··· 14 14 and discards your data. Use for stm class testing. 15 15 16 16 If you don't know what this is, say N. 17 + 18 + config STM_SOURCE_CONSOLE 19 + tristate "Kernel console over STM devices" 20 + help 21 + This is a kernel space trace source that sends kernel log 22 + messages to trace hosts over STM devices. 23 + 24 + If you want to send kernel console messages over STM devices, 25 + say Y.
+4
drivers/hwtracing/stm/Makefile
··· 3 3 stm_core-y := core.o policy.o 4 4 5 5 obj-$(CONFIG_STM_DUMMY) += dummy_stm.o 6 + 7 + obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o 8 + 9 + stm_console-y := console.o
+80
drivers/hwtracing/stm/console.c
··· 1 + /* 2 + * Simple kernel console driver for STM devices 3 + * Copyright (c) 2014, Intel Corporation. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + * 14 + * STM console will send kernel messages over STM devices to a trace host. 15 + */ 16 + 17 + #include <linux/kernel.h> 18 + #include <linux/module.h> 19 + #include <linux/console.h> 20 + #include <linux/slab.h> 21 + #include <linux/stm.h> 22 + 23 + static int stm_console_link(struct stm_source_data *data); 24 + static void stm_console_unlink(struct stm_source_data *data); 25 + 26 + static struct stm_console { 27 + struct stm_source_data data; 28 + struct console console; 29 + } stm_console = { 30 + .data = { 31 + .name = "console", 32 + .nr_chans = 1, 33 + .link = stm_console_link, 34 + .unlink = stm_console_unlink, 35 + }, 36 + }; 37 + 38 + static void 39 + stm_console_write(struct console *con, const char *buf, unsigned len) 40 + { 41 + struct stm_console *sc = container_of(con, struct stm_console, console); 42 + 43 + stm_source_write(&sc->data, 0, buf, len); 44 + } 45 + 46 + static int stm_console_link(struct stm_source_data *data) 47 + { 48 + struct stm_console *sc = container_of(data, struct stm_console, data); 49 + 50 + strcpy(sc->console.name, "stm_console"); 51 + sc->console.write = stm_console_write; 52 + sc->console.flags = CON_ENABLED | CON_PRINTBUFFER; 53 + register_console(&sc->console); 54 + 55 + return 0; 56 + } 57 + 58 + static void stm_console_unlink(struct stm_source_data *data) 59 + { 60 + struct stm_console *sc = container_of(data, struct stm_console, data); 61 + 62 + unregister_console(&sc->console); 63 + } 64 + 65 + static int stm_console_init(void) 66 + { 67 + return stm_source_register_device(NULL, &stm_console.data); 68 + } 69 + 70 + static void stm_console_exit(void) 71 + { 72 + stm_source_unregister_device(&stm_console.data); 73 + } 74 + 75 + module_init(stm_console_init); 76 + module_exit(stm_console_exit); 77 + 78 + MODULE_LICENSE("GPL v2"); 79 + MODULE_DESCRIPTION("stm_console driver"); 80 + MODULE_AUTHOR("Alexander Shishkin <alexander.shishkin@linux.intel.com>");