Skip to content

Commit a773d41

Browse files
Felipe Balbirostedt
authored andcommitted
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>
1 parent c4bfd39 commit a773d41

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/hwtracing/stm/ftrace.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ static struct stm_ftrace {
4242
* @len: length of the data packet
4343
*/
4444
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)
4646
{
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);
4850
}
4951

5052
static int stm_ftrace_link(struct stm_source_data *data)

‎include/linux/trace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
struct trace_export {
2020
struct trace_export __rcu *next;
21-
void (*write)(const void *, unsigned int);
21+
void (*write)(struct trace_export *, const void *, unsigned int);
2222
};
2323

2424
int register_ftrace_export(struct trace_export *export);

‎kernel/trace/trace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,7 @@ trace_process_export(struct trace_export *export,
24152415

24162416
entry = ring_buffer_event_data(event);
24172417
size = ring_buffer_event_length(event);
2418-
export->write(entry, size);
2418+
export->write(export, entry, size);
24192419
}
24202420

24212421
static DEFINE_MUTEX(ftrace_export_lock);

0 commit comments

Comments
 (0)