1 /* I2C message transfer tracepoints
3 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
12 #define TRACE_SYSTEM i2c
14 #if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ)
17 #include <linux/i2c.h>
18 #include <linux/tracepoint.h>
21 * drivers/i2c/i2c-core-base.c
23 extern int i2c_transfer_trace_reg(void);
24 extern void i2c_transfer_trace_unreg(void);
27 * __i2c_transfer() write request
29 TRACE_EVENT_FN(i2c_write
,
30 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
32 TP_ARGS(adap
, msg
, num
),
34 __field(int, adapter_nr
)
35 __field(__u16
, msg_nr
)
37 __field(__u16
, flags
)
39 __dynamic_array(__u8
, buf
, msg
->len
) ),
41 __entry
->adapter_nr
= adap
->nr
;
42 __entry
->msg_nr
= num
;
43 __entry
->addr
= msg
->addr
;
44 __entry
->flags
= msg
->flags
;
45 __entry
->len
= msg
->len
;
46 memcpy(__get_dynamic_array(buf
), msg
->buf
, msg
->len
);
48 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
54 __entry
->len
, __get_dynamic_array(buf
)
56 i2c_transfer_trace_reg
,
57 i2c_transfer_trace_unreg
);
60 * __i2c_transfer() read request
62 TRACE_EVENT_FN(i2c_read
,
63 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
65 TP_ARGS(adap
, msg
, num
),
67 __field(int, adapter_nr
)
68 __field(__u16
, msg_nr
)
70 __field(__u16
, flags
)
74 __entry
->adapter_nr
= adap
->nr
;
75 __entry
->msg_nr
= num
;
76 __entry
->addr
= msg
->addr
;
77 __entry
->flags
= msg
->flags
;
78 __entry
->len
= msg
->len
;
80 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u",
87 i2c_transfer_trace_reg
,
88 i2c_transfer_trace_unreg
);
91 * __i2c_transfer() read reply
93 TRACE_EVENT_FN(i2c_reply
,
94 TP_PROTO(const struct i2c_adapter
*adap
, const struct i2c_msg
*msg
,
96 TP_ARGS(adap
, msg
, num
),
98 __field(int, adapter_nr
)
99 __field(__u16
, msg_nr
)
100 __field(__u16
, addr
)
101 __field(__u16
, flags
)
103 __dynamic_array(__u8
, buf
, msg
->len
) ),
105 __entry
->adapter_nr
= adap
->nr
;
106 __entry
->msg_nr
= num
;
107 __entry
->addr
= msg
->addr
;
108 __entry
->flags
= msg
->flags
;
109 __entry
->len
= msg
->len
;
110 memcpy(__get_dynamic_array(buf
), msg
->buf
, msg
->len
);
112 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]",
118 __entry
->len
, __get_dynamic_array(buf
)
120 i2c_transfer_trace_reg
,
121 i2c_transfer_trace_unreg
);
124 * __i2c_transfer() result
126 TRACE_EVENT_FN(i2c_result
,
127 TP_PROTO(const struct i2c_adapter
*adap
, int num
, int ret
),
128 TP_ARGS(adap
, num
, ret
),
130 __field(int, adapter_nr
)
131 __field(__u16
, nr_msgs
)
135 __entry
->adapter_nr
= adap
->nr
;
136 __entry
->nr_msgs
= num
;
139 TP_printk("i2c-%d n=%u ret=%d",
144 i2c_transfer_trace_reg
,
145 i2c_transfer_trace_unreg
);
147 #endif /* _TRACE_I2C_H */
149 /* This part must be outside protection */
150 #include <trace/define_trace.h>