1 /* SMBUS 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 smbus
14 #if !defined(_TRACE_SMBUS_H) || defined(TRACE_HEADER_MULTI_READ)
15 #define _TRACE_SMBUS_H
17 #include <linux/i2c.h>
18 #include <linux/tracepoint.h>
21 * drivers/i2c/i2c-core-smbus.c
25 * i2c_smbus_xfer() write data or procedure call request
27 TRACE_EVENT_CONDITION(smbus_write
,
28 TP_PROTO(const struct i2c_adapter
*adap
,
29 u16 addr
, unsigned short flags
,
30 char read_write
, u8 command
, int protocol
,
31 const union i2c_smbus_data
*data
),
32 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
),
33 TP_CONDITION(read_write
== I2C_SMBUS_WRITE
||
34 protocol
== I2C_SMBUS_PROC_CALL
||
35 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
),
37 __field(int, adapter_nr
)
39 __field(__u16
, flags
)
40 __field(__u8
, command
)
42 __field(__u32
, protocol
)
43 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
45 __entry
->adapter_nr
= adap
->nr
;
47 __entry
->flags
= flags
;
48 __entry
->command
= command
;
49 __entry
->protocol
= protocol
;
52 case I2C_SMBUS_BYTE_DATA
:
55 case I2C_SMBUS_WORD_DATA
:
56 case I2C_SMBUS_PROC_CALL
:
59 case I2C_SMBUS_BLOCK_DATA
:
60 case I2C_SMBUS_BLOCK_PROC_CALL
:
61 case I2C_SMBUS_I2C_BLOCK_DATA
:
62 __entry
->len
= data
->block
[0] + 1;
64 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
68 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
73 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
78 __print_symbolic(__entry
->protocol
,
79 { I2C_SMBUS_QUICK
, "QUICK" },
80 { I2C_SMBUS_BYTE
, "BYTE" },
81 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
82 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
83 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
84 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
85 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
86 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
87 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
89 __entry
->len
, __entry
->buf
93 * i2c_smbus_xfer() read data request
95 TRACE_EVENT_CONDITION(smbus_read
,
96 TP_PROTO(const struct i2c_adapter
*adap
,
97 u16 addr
, unsigned short flags
,
98 char read_write
, u8 command
, int protocol
),
99 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
),
100 TP_CONDITION(!(read_write
== I2C_SMBUS_WRITE
||
101 protocol
== I2C_SMBUS_PROC_CALL
||
102 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
)),
104 __field(int, adapter_nr
)
105 __field(__u16
, flags
)
106 __field(__u16
, addr
)
107 __field(__u8
, command
)
108 __field(__u32
, protocol
)
109 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
111 __entry
->adapter_nr
= adap
->nr
;
112 __entry
->addr
= addr
;
113 __entry
->flags
= flags
;
114 __entry
->command
= command
;
115 __entry
->protocol
= protocol
;
117 TP_printk("i2c-%d a=%03x f=%04x c=%x %s",
122 __print_symbolic(__entry
->protocol
,
123 { I2C_SMBUS_QUICK
, "QUICK" },
124 { I2C_SMBUS_BYTE
, "BYTE" },
125 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
126 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
127 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
128 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
129 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
130 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
131 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" })
135 * i2c_smbus_xfer() read data or procedure call reply
137 TRACE_EVENT_CONDITION(smbus_reply
,
138 TP_PROTO(const struct i2c_adapter
*adap
,
139 u16 addr
, unsigned short flags
,
140 char read_write
, u8 command
, int protocol
,
141 const union i2c_smbus_data
*data
),
142 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
),
143 TP_CONDITION(read_write
== I2C_SMBUS_READ
),
145 __field(int, adapter_nr
)
146 __field(__u16
, addr
)
147 __field(__u16
, flags
)
148 __field(__u8
, command
)
150 __field(__u32
, protocol
)
151 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
153 __entry
->adapter_nr
= adap
->nr
;
154 __entry
->addr
= addr
;
155 __entry
->flags
= flags
;
156 __entry
->command
= command
;
157 __entry
->protocol
= protocol
;
161 case I2C_SMBUS_BYTE_DATA
:
164 case I2C_SMBUS_WORD_DATA
:
165 case I2C_SMBUS_PROC_CALL
:
168 case I2C_SMBUS_BLOCK_DATA
:
169 case I2C_SMBUS_BLOCK_PROC_CALL
:
170 case I2C_SMBUS_I2C_BLOCK_DATA
:
171 __entry
->len
= data
->block
[0] + 1;
173 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
175 case I2C_SMBUS_QUICK
:
176 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
181 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
186 __print_symbolic(__entry
->protocol
,
187 { I2C_SMBUS_QUICK
, "QUICK" },
188 { I2C_SMBUS_BYTE
, "BYTE" },
189 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
190 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
191 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
192 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
193 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
194 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
195 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
197 __entry
->len
, __entry
->buf
201 * i2c_smbus_xfer() result
203 TRACE_EVENT(smbus_result
,
204 TP_PROTO(const struct i2c_adapter
*adap
,
205 u16 addr
, unsigned short flags
,
206 char read_write
, u8 command
, int protocol
,
208 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, res
),
210 __field(int, adapter_nr
)
211 __field(__u16
, addr
)
212 __field(__u16
, flags
)
213 __field(__u8
, read_write
)
214 __field(__u8
, command
)
216 __field(__u32
, protocol
)
219 __entry
->adapter_nr
= adap
->nr
;
220 __entry
->addr
= addr
;
221 __entry
->flags
= flags
;
222 __entry
->read_write
= read_write
;
223 __entry
->command
= command
;
224 __entry
->protocol
= protocol
;
227 TP_printk("i2c-%d a=%03x f=%04x c=%x %s %s res=%d",
232 __print_symbolic(__entry
->protocol
,
233 { I2C_SMBUS_QUICK
, "QUICK" },
234 { I2C_SMBUS_BYTE
, "BYTE" },
235 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
236 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
237 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
238 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
239 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
240 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
241 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
242 __entry
->read_write
== I2C_SMBUS_WRITE
? "wr" : "rd",
246 #endif /* _TRACE_SMBUS_H */
248 /* This part must be outside protection */
249 #include <trace/define_trace.h>