[PATCH RFC v2 4/4] siox: add support for tracing
From: Uwe Kleine-KÃnig
Date: Mon Mar 21 2016 - 06:05:36 EST
---
drivers/siox/siox-core.c | 12 +++++++++
include/trace/events/siox.h | 60 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
create mode 100644 include/trace/events/siox.h
diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c
index b4a128218d7d..9d9c04c5de59 100644
--- a/drivers/siox/siox-core.c
+++ b/drivers/siox/siox-core.c
@@ -13,6 +13,9 @@
#include "siox.h"
+#define CREATE_TRACE_POINTS
+#include <trace/events/siox.h>
+
struct workqueue_struct *wqueue;
static bool siox_is_registered;
@@ -33,6 +36,7 @@ static void __siox_poll(struct siox_master *smaster)
{
struct siox_device *sdevice;
size_t i = 0;
+ unsigned int devno = smaster->num_devices;
u8 prevstatus = smaster->status;
if (++smaster->status > 0x0d)
@@ -44,16 +48,21 @@ static void __siox_poll(struct siox_master *smaster)
struct siox_driver *sdriver =
sdevice->dev.driver ? to_siox_driver(sdevice->dev.driver) : NULL;
+ devno--;
+
if (sdriver)
sdriver->set_data(sdevice, smaster->status,
&smaster->buf[i + 1]);
smaster->buf[i] = smaster->status;
+ trace_siox_set_data(smaster, sdevice, devno, i);
+
i += sdevice->inbytes;
}
BUG_ON(i != smaster->setbuf_len);
+ BUG_ON(devno);
smaster->pushpull(smaster, smaster->setbuf_len, smaster->buf,
smaster->getbuf_len,
@@ -91,9 +100,12 @@ static void __siox_poll(struct siox_master *smaster)
* counter. Should the bus stop to poll in these cases?
*/
+ trace_siox_get_data(smaster, sdevice, devno, i);
+
if (sdriver)
sdriver->get_data(sdevice, &smaster->buf[i]);
+ devno++;
i += sdevice->outbytes;
}
diff --git a/include/trace/events/siox.h b/include/trace/events/siox.h
new file mode 100644
index 000000000000..1cc1a0eea12b
--- /dev/null
+++ b/include/trace/events/siox.h
@@ -0,0 +1,60 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM siox
+
+#if !defined(_TRACE_SIOX_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SIOX_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(siox_set_data,
+ TP_PROTO(const struct siox_master *smaster,
+ const struct siox_device *sdevice,
+ unsigned int devno, size_t bufoffset),
+ TP_ARGS(smaster, sdevice, devno, bufoffset),
+ TP_STRUCT__entry(
+ __field(int, busno)
+ __field(unsigned int, devno)
+ __field(size_t, inbytes)
+ __dynamic_array(u8, buf, sdevice->inbytes)
+ ),
+ TP_fast_assign(
+ __entry->busno = smaster->busno;
+ __entry->devno = devno;
+ __entry->inbytes = sdevice->inbytes;
+ memcpy(__get_dynamic_array(buf), smaster->buf + bufoffset, sdevice->inbytes);
+ ),
+ TP_printk("siox-%d-%u [%*phD]",
+ __entry->busno,
+ __entry->devno,
+ __entry->inbytes, __get_dynamic_array(buf)
+ )
+);
+
+TRACE_EVENT(siox_get_data,
+ TP_PROTO(const struct siox_master *smaster,
+ const struct siox_device *sdevice,
+ unsigned int devno, size_t bufoffset),
+ TP_ARGS(smaster, sdevice, devno, bufoffset),
+ TP_STRUCT__entry(
+ __field(int, busno)
+ __field(unsigned int, devno)
+ __field(size_t, outbytes)
+ __dynamic_array(u8, buf, sdevice->outbytes)
+ ),
+ TP_fast_assign(
+ __entry->busno = smaster->busno;
+ __entry->devno = devno;
+ __entry->outbytes = sdevice->outbytes;
+ memcpy(__get_dynamic_array(buf), smaster->buf + bufoffset, sdevice->outbytes);
+ ),
+ TP_printk("siox-%d-%u [%*phD]",
+ __entry->busno,
+ __entry->devno,
+ __entry->outbytes, __get_dynamic_array(buf)
+ )
+);
+
+#endif /* if !defined(_TRACE_SIOX_H) || defined(TRACE_HEADER_MULTI_READ) */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.7.0