[PATCH] drivers: i2c-core: Add trace events for i2c_master_send()/i2c_master_recv()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add basic trace events for i2c_master_send() and i2c_master_recv() so we
can observe the I2C activity without filling up the dmesg ring buffer.  It
also makes it easy to enable and disable tracing of the i2c-core.

Signed-off-by: Dimitris Papastamos <dp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
---
 drivers/i2c/i2c-core.c     |    4 +++
 include/trace/events/i2c.h |   55 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)
 create mode 100644 include/trace/events/i2c.h

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index f0bd5bc..2c2bb45 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -42,6 +42,8 @@
 
 #include "i2c-core.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/i2c.h>
 
 /* core_lock protects i2c_adapter_idr, and guarantees
    that device detection, deletion of detected devices, and attach_adapter
@@ -1366,6 +1368,7 @@ int i2c_master_send(const struct i2c_client *client, const char *buf, int count)
 	msg.buf = (char *)buf;
 
 	ret = i2c_transfer(adap, &msg, 1);
+	trace_i2c_master_send(&msg, ret);
 
 	/* If everything went ok (i.e. 1 msg transmitted), return #bytes
 	   transmitted, else error code. */
@@ -1394,6 +1397,7 @@ int i2c_master_recv(const struct i2c_client *client, char *buf, int count)
 	msg.buf = buf;
 
 	ret = i2c_transfer(adap, &msg, 1);
+	trace_i2c_master_recv(&msg, ret);
 
 	/* If everything went ok (i.e. 1 msg transmitted), return #bytes
 	   transmitted, else error code. */
diff --git a/include/trace/events/i2c.h b/include/trace/events/i2c.h
new file mode 100644
index 0000000..cdf64e8
--- /dev/null
+++ b/include/trace/events/i2c.h
@@ -0,0 +1,55 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM i2c
+
+#if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_I2C_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+struct i2c_msg;
+
+DECLARE_EVENT_CLASS(i2c_master,
+
+	TP_PROTO(struct i2c_msg *msg, int ret),
+
+	TP_ARGS(msg, ret),
+
+	TP_STRUCT__entry(
+		__field(	u16,	addr	)
+		__field(	u16,	len	)
+		__field(	u16,	flags	)
+		__field(	int,	ret	)
+	),
+
+	TP_fast_assign(
+		__entry->addr = msg->addr;
+		__entry->len = msg->len;
+		__entry->flags = msg->flags;
+		__entry->ret = ret;
+	),
+
+	TP_printk("addr=%x len=%x flags=%x ret=%d", (u16)__entry->addr,
+		  (u16)__entry->len, (u16)__entry->flags, (int)__entry->ret)
+);
+
+DEFINE_EVENT(i2c_master, i2c_master_send,
+
+	TP_PROTO(struct i2c_msg *msg, int ret),
+
+	TP_ARGS(msg, ret)
+
+);
+
+DEFINE_EVENT(i2c_master, i2c_master_recv,
+
+	TP_PROTO(struct i2c_msg *msg, int ret),
+
+	TP_ARGS(msg, ret)
+
+);
+
+#endif /* _TRACE_I2C_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
-- 
1.7.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux