Skip to content

Commit

Permalink
tracing: Pass export pointer as argument to ->write()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Balbi authored and Steven Rostedt (VMware) committed Dec 4, 2017
1 parent c4bfd39 commit a773d41
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drivers/hwtracing/stm/ftrace.c
Original file line number Diff line number Diff line change
@@ -42,9 +42,11 @@ static struct stm_ftrace {
* @len: length of the data packet
*/
static void notrace
stm_ftrace_write(const void *buf, unsigned int len)
stm_ftrace_write(struct trace_export *export, const void *buf, unsigned int len)
{
stm_source_write(&stm_ftrace.data, STM_FTRACE_CHAN, buf, len);
struct stm_ftrace *stm = container_of(export, struct stm_ftrace, ftrace);

stm_source_write(&stm->data, STM_FTRACE_CHAN, buf, len);
}

static int stm_ftrace_link(struct stm_source_data *data)
2 changes: 1 addition & 1 deletion include/linux/trace.h
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
*/
struct trace_export {
struct trace_export __rcu *next;
void (*write)(const void *, unsigned int);
void (*write)(struct trace_export *, const void *, unsigned int);
};

int register_ftrace_export(struct trace_export *export);
2 changes: 1 addition & 1 deletion kernel/trace/trace.c
Original file line number Diff line number Diff line change
@@ -2415,7 +2415,7 @@ trace_process_export(struct trace_export *export,

entry = ring_buffer_event_data(event);
size = ring_buffer_event_length(event);
export->write(entry, size);
export->write(export, entry, size);
}

static DEFINE_MUTEX(ftrace_export_lock);

0 comments on commit a773d41

Please sign in to comment.