Skip to contentSkip to conversation

drivers: i2c-core: Add trace events for i2c/smbus transfer functions

PATCH New Dimitris Papastamos 1 participant 1 message Jan 28, 2011

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

PATCH 1/1 drivers: i2c-core: Add trace events for i2c/smbus transfer functions

Add basic trace events for i2c_transfer() and i2c_smbus_xfer() so we can observe the I2C/SMBus activity without filling up the dmesg ring buffer.

---
 drivers/i2c/i2c-core.c     |    8 ++++-
 include/trace/events/i2c.h |   70 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 1 deletions(-)
 create mode 100644 include/trace/events/i2c.h
drivers/i2c/i2c-core.c +7 -1
index f0bd5bc..848f0fc 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
@@ -1289,7 +1291,7 @@ module_exit(i2c_exit);
 int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 {
 	unsigned long orig_jiffies;
-	int ret, try;
+	int ret, try, i;
 
 	/* REVISIT the fault reporting model here is weak:
 	 *
@@ -1330,6 +1332,8 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 		/* Retry automatically on arbitration loss */
 		orig_jiffies = jiffies;
 		for (ret = 0, try = 0; try <= adap->retries; try++) {
+			for (i = 0; i < num; i++)
+				trace_i2c_transfer(adap->name, &msgs[i]);
 			ret = adap->algo->master_xfer(adap, msgs, num);
 			if (ret != -EAGAIN)
 				break;
@@ -2089,6 +2093,8 @@ s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, unsigned short flags,
 		/* Retry automatically on arbitration loss */
 		orig_jiffies = jiffies;
 		for (res = 0, try = 0; try <= adapter->retries; try++) {
+			trace_i2c_smbus_xfer(adapter->name, addr, flags,
+					     read_write, command, protocol);
 			res = adapter->algo->smbus_xfer(adapter, addr, flags,
 							read_write, command,
 							protocol, data);
include/trace/events/i2c.h new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
1.7.3.5