Skip to contentSkip to conversation

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

PATCH In review Dimitris Papastamos 3 participants 3 messages Jan 27, 2011 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 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
drivers/i2c/i2c-core.c +4 -0
index f0bd5bc..2c2bb45 100644
@@ -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. */
include/trace/events/i2c.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.3.5

A message that is not in the archive (sent off-list or not yet received): 1296126066-15951-1-git-send-email-dp-yzvPICuk2AATkU/[email protected]

#2 lore raw
Quoted 3 lines · Dimitris Papastamos

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.

This doesn't make sense. If you want to trace something, trace i2c_transfer(). i2c_master_send() and i2c_master_recv() are only helpers for the most simple cases, so tracing only them is pointless.

Note that even with this, you'll miss calls to i2c_smbus_xfer(), which is the other access point to I2C/SMBus controllers. So I guess you want to trace it as well.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 6 lines · Jean Delvare
Quoted 3 lines · Dimitris Papastamos

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.

Quoted 7 lines

This doesn't make sense. If you want to trace something, trace i2c_transfer(). i2c_master_send() and i2c_master_recv() are only helpers for the most simple cases, so tracing only them is pointless.

Note that even with this, you'll miss calls to i2c_smbus_xfer(), which is the other access point to I2C/SMBus controllers. So I guess you want to trace it as well.

Might also be interesting to do start/stop tracing - I2C is relatively slow and causes scheduling. Dunno if it's worth it, though you could always turn on only one of the events if it was too boring to have both.