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

tracing: Pass export pointer as argument to ->write()

By passing an export descriptor to the write function, users don't need to
keep a global static pointer and can rely on container_of() to fetch their
own structure.

Link: http://lkml.kernel.org/r/20170602102025.5140-1-felipe.balbi@linux.intel.com

Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Felipe Balbi and committed by
Steven Rostedt (VMware)
a773d419 c4bfd39d

+6 -4
+4 -2
drivers/hwtracing/stm/ftrace.c
··· 42 42 * @len: length of the data packet 43 43 */ 44 44 static void notrace 45 - stm_ftrace_write(const void *buf, unsigned int len) 45 + stm_ftrace_write(struct trace_export *export, const void *buf, unsigned int len) 46 46 { 47 - stm_source_write(&stm_ftrace.data, STM_FTRACE_CHAN, buf, len); 47 + struct stm_ftrace *stm = container_of(export, struct stm_ftrace, ftrace); 48 + 49 + stm_source_write(&stm->data, STM_FTRACE_CHAN, buf, len); 48 50 } 49 51 50 52 static int stm_ftrace_link(struct stm_source_data *data)
+1 -1
include/linux/trace.h
··· 18 18 */ 19 19 struct trace_export { 20 20 struct trace_export __rcu *next; 21 - void (*write)(const void *, unsigned int); 21 + void (*write)(struct trace_export *, const void *, unsigned int); 22 22 }; 23 23 24 24 int register_ftrace_export(struct trace_export *export);
+1 -1
kernel/trace/trace.c
··· 2415 2415 2416 2416 entry = ring_buffer_event_data(event); 2417 2417 size = ring_buffer_event_length(event); 2418 - export->write(entry, size); 2418 + export->write(export, entry, size); 2419 2419 } 2420 2420 2421 2421 static DEFINE_MUTEX(ftrace_export_lock);