1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* SMBUS message transfer tracepoints
4 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
8 #define TRACE_SYSTEM smbus
10 #if !defined(_TRACE_SMBUS_H) || defined(TRACE_HEADER_MULTI_READ)
11 #define _TRACE_SMBUS_H
13 #include <linux/i2c.h>
14 #include <linux/tracepoint.h>
17 * drivers/i2c/i2c-core-smbus.c
21 * i2c_smbus_xfer() write data or procedure call request
23 TRACE_EVENT_CONDITION(smbus_write
,
24 TP_PROTO(const struct i2c_adapter
*adap
,
25 u16 addr
, unsigned short flags
,
26 char read_write
, u8 command
, int protocol
,
27 const union i2c_smbus_data
*data
),
28 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
),
29 TP_CONDITION(read_write
== I2C_SMBUS_WRITE
||
30 protocol
== I2C_SMBUS_PROC_CALL
||
31 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
),
33 __field(int, adapter_nr
)
35 __field(__u16
, flags
)
36 __field(__u8
, command
)
38 __field(__u32
, protocol
)
39 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
41 __entry
->adapter_nr
= adap
->nr
;
43 __entry
->flags
= flags
;
44 __entry
->command
= command
;
45 __entry
->protocol
= protocol
;
48 case I2C_SMBUS_BYTE_DATA
:
51 case I2C_SMBUS_WORD_DATA
:
52 case I2C_SMBUS_PROC_CALL
:
55 case I2C_SMBUS_BLOCK_DATA
:
56 case I2C_SMBUS_BLOCK_PROC_CALL
:
57 case I2C_SMBUS_I2C_BLOCK_DATA
:
58 __entry
->len
= data
->block
[0] + 1;
60 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
64 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
69 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
74 __print_symbolic(__entry
->protocol
,
75 { I2C_SMBUS_QUICK
, "QUICK" },
76 { I2C_SMBUS_BYTE
, "BYTE" },
77 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
78 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
79 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
80 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
81 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
82 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
83 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
85 __entry
->len
, __entry
->buf
89 * i2c_smbus_xfer() read data request
91 TRACE_EVENT_CONDITION(smbus_read
,
92 TP_PROTO(const struct i2c_adapter
*adap
,
93 u16 addr
, unsigned short flags
,
94 char read_write
, u8 command
, int protocol
),
95 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
),
96 TP_CONDITION(!(read_write
== I2C_SMBUS_WRITE
||
97 protocol
== I2C_SMBUS_PROC_CALL
||
98 protocol
== I2C_SMBUS_BLOCK_PROC_CALL
)),
100 __field(int, adapter_nr
)
101 __field(__u16
, flags
)
102 __field(__u16
, addr
)
103 __field(__u8
, command
)
104 __field(__u32
, protocol
)
105 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
107 __entry
->adapter_nr
= adap
->nr
;
108 __entry
->addr
= addr
;
109 __entry
->flags
= flags
;
110 __entry
->command
= command
;
111 __entry
->protocol
= protocol
;
113 TP_printk("i2c-%d a=%03x f=%04x c=%x %s",
118 __print_symbolic(__entry
->protocol
,
119 { I2C_SMBUS_QUICK
, "QUICK" },
120 { I2C_SMBUS_BYTE
, "BYTE" },
121 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
122 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
123 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
124 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
125 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
126 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
127 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" })
131 * i2c_smbus_xfer() read data or procedure call reply
133 TRACE_EVENT_CONDITION(smbus_reply
,
134 TP_PROTO(const struct i2c_adapter
*adap
,
135 u16 addr
, unsigned short flags
,
136 char read_write
, u8 command
, int protocol
,
137 const union i2c_smbus_data
*data
, int res
),
138 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, data
, res
),
139 TP_CONDITION(res
>= 0 && read_write
== I2C_SMBUS_READ
),
141 __field(int, adapter_nr
)
142 __field(__u16
, addr
)
143 __field(__u16
, flags
)
144 __field(__u8
, command
)
146 __field(__u32
, protocol
)
147 __array(__u8
, buf
, I2C_SMBUS_BLOCK_MAX
+ 2) ),
149 __entry
->adapter_nr
= adap
->nr
;
150 __entry
->addr
= addr
;
151 __entry
->flags
= flags
;
152 __entry
->command
= command
;
153 __entry
->protocol
= protocol
;
157 case I2C_SMBUS_BYTE_DATA
:
160 case I2C_SMBUS_WORD_DATA
:
161 case I2C_SMBUS_PROC_CALL
:
164 case I2C_SMBUS_BLOCK_DATA
:
165 case I2C_SMBUS_BLOCK_PROC_CALL
:
166 case I2C_SMBUS_I2C_BLOCK_DATA
:
167 __entry
->len
= data
->block
[0] + 1;
169 memcpy(__entry
->buf
, data
->block
, __entry
->len
);
171 case I2C_SMBUS_QUICK
:
172 case I2C_SMBUS_I2C_BLOCK_BROKEN
:
177 TP_printk("i2c-%d a=%03x f=%04x c=%x %s l=%u [%*phD]",
182 __print_symbolic(__entry
->protocol
,
183 { I2C_SMBUS_QUICK
, "QUICK" },
184 { I2C_SMBUS_BYTE
, "BYTE" },
185 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
186 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
187 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
188 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
189 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
190 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
191 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
193 __entry
->len
, __entry
->buf
197 * i2c_smbus_xfer() result
199 TRACE_EVENT(smbus_result
,
200 TP_PROTO(const struct i2c_adapter
*adap
,
201 u16 addr
, unsigned short flags
,
202 char read_write
, u8 command
, int protocol
,
204 TP_ARGS(adap
, addr
, flags
, read_write
, command
, protocol
, res
),
206 __field(int, adapter_nr
)
207 __field(__u16
, addr
)
208 __field(__u16
, flags
)
209 __field(__u8
, read_write
)
210 __field(__u8
, command
)
212 __field(__u32
, protocol
)
215 __entry
->adapter_nr
= adap
->nr
;
216 __entry
->addr
= addr
;
217 __entry
->flags
= flags
;
218 __entry
->read_write
= read_write
;
219 __entry
->command
= command
;
220 __entry
->protocol
= protocol
;
223 TP_printk("i2c-%d a=%03x f=%04x c=%x %s %s res=%d",
228 __print_symbolic(__entry
->protocol
,
229 { I2C_SMBUS_QUICK
, "QUICK" },
230 { I2C_SMBUS_BYTE
, "BYTE" },
231 { I2C_SMBUS_BYTE_DATA
, "BYTE_DATA" },
232 { I2C_SMBUS_WORD_DATA
, "WORD_DATA" },
233 { I2C_SMBUS_PROC_CALL
, "PROC_CALL" },
234 { I2C_SMBUS_BLOCK_DATA
, "BLOCK_DATA" },
235 { I2C_SMBUS_I2C_BLOCK_BROKEN
, "I2C_BLOCK_BROKEN" },
236 { I2C_SMBUS_BLOCK_PROC_CALL
, "BLOCK_PROC_CALL" },
237 { I2C_SMBUS_I2C_BLOCK_DATA
, "I2C_BLOCK_DATA" }),
238 __entry
->read_write
== I2C_SMBUS_WRITE
? "wr" : "rd",
242 #endif /* _TRACE_SMBUS_H */
244 /* This part must be outside protection */
245 #include <trace/define_trace.h>