Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751217AbdFBKVE (ORCPT ); Fri, 2 Jun 2017 06:21:04 -0400 Received: from mga03.intel.com ([134.134.136.65]:12766 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbdFBKVD (ORCPT ); Fri, 2 Jun 2017 06:21:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,284,1493708400"; d="scan'208";a="863874299" From: Felipe Balbi To: Alexander Shishkin , Steven Rostedt , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Chunyan Zhang , Felipe Balbi Subject: [PATCH v2] kernel: trace: pass export pointer as argument to ->write() Date: Fri, 2 Jun 2017 13:20:25 +0300 Message-Id: <20170602102025.5140-1-felipe.balbi@linux.intel.com> X-Mailer: git-send-email 2.11.0.295.gd7dffce1ce In-Reply-To: <201705181922.glbnZKEM%fengguang.wu@intel.com> References: <201705181922.glbnZKEM%fengguang.wu@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2077 Lines: 62 That way, users don't need to keep a global static pointer and can rely on container_of() to fetch their own structure. Acked-by: Steven Rostedt (VMware) Reviewed-by: Chunyan Zhang Signed-off-by: Felipe Balbi --- Changes since v1: - add missing & operator drivers/hwtracing/stm/ftrace.c | 6 ++++-- include/linux/trace.h | 2 +- kernel/trace/trace.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/stm/ftrace.c b/drivers/hwtracing/stm/ftrace.c index bd126a7c6da2..7da75644c750 100644 --- a/drivers/hwtracing/stm/ftrace.c +++ b/drivers/hwtracing/stm/ftrace.c @@ -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) diff --git a/include/linux/trace.h b/include/linux/trace.h index 9330a58e2651..477aed6f0caa 100644 --- a/include/linux/trace.h +++ b/include/linux/trace.h @@ -17,7 +17,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); diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1122f151466f..d0b5e8baa858 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2317,7 +2317,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); -- 2.11.0.295.gd7dffce1ce