xref: /linux/drivers/iio/imu/bno055/bno055_ser_trace.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #if !defined(__BNO055_SERDEV_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
4 #define __BNO055_SERDEV_TRACE_H__
5 
6 #include <linux/tracepoint.h>
7 
8 #undef TRACE_SYSTEM
9 #define TRACE_SYSTEM bno055_ser
10 
11 TRACE_EVENT(send_chunk,
12 	    TP_PROTO(int len, const u8 *data),
13 	    TP_ARGS(len, data),
14 	    TP_STRUCT__entry(
15 		    __field(int, len)
16 		    __dynamic_array(u8, chunk, len)
17 	    ),
18 	    TP_fast_assign(
19 		    __entry->len = len;
20 		    memcpy(__get_dynamic_array(chunk),
21 			   data, __entry->len);
22 	    ),
23 	    TP_printk("len: %d, data: = %*ph",
24 		      __entry->len, __entry->len, __get_dynamic_array(chunk)
25 	    )
26 );
27 
28 TRACE_EVENT(cmd_retry,
29 	    TP_PROTO(bool read, int addr, int retry),
30 	    TP_ARGS(read, addr, retry),
31 	    TP_STRUCT__entry(
32 		    __field(bool, read)
33 		    __field(int, addr)
34 		    __field(int, retry)
35 	    ),
36 	    TP_fast_assign(
37 		    __entry->read = read;
38 		    __entry->addr = addr;
39 		    __entry->retry = retry;
40 	    ),
41 	    TP_printk("%s addr 0x%x retry #%d",
42 		      __entry->read ? "read" : "write",
43 		      __entry->addr, __entry->retry
44 	    )
45 );
46 
47 TRACE_EVENT(write_reg,
48 	    TP_PROTO(u8 addr, u8 value),
49 	    TP_ARGS(addr, value),
50 	    TP_STRUCT__entry(
51 		    __field(u8, addr)
52 		    __field(u8, value)
53 	    ),
54 	    TP_fast_assign(
55 		    __entry->addr = addr;
56 		    __entry->value = value;
57 	    ),
58 	    TP_printk("reg 0x%x = 0x%x",
59 		      __entry->addr, __entry->value
60 	    )
61 );
62 
63 TRACE_EVENT(read_reg,
64 	    TP_PROTO(int addr, size_t len),
65 	    TP_ARGS(addr, len),
66 	    TP_STRUCT__entry(
67 		    __field(int, addr)
68 		    __field(size_t, len)
69 	    ),
70 	    TP_fast_assign(
71 		    __entry->addr = addr;
72 		    __entry->len = len;
73 	    ),
74 	    TP_printk("reg 0x%x (len %zu)",
75 		      __entry->addr, __entry->len
76 	    )
77 );
78 
79 TRACE_EVENT(recv,
80 	    TP_PROTO(size_t len, const unsigned char *buf),
81 	    TP_ARGS(len, buf),
82 	    TP_STRUCT__entry(
83 		    __field(size_t, len)
84 		    __dynamic_array(unsigned char, buf, len)
85 	    ),
86 	    TP_fast_assign(
87 		    __entry->len = len;
88 		    memcpy(__get_dynamic_array(buf),
89 			   buf, __entry->len);
90 	    ),
91 	    TP_printk("len: %zu, data: = %*ph",
92 		      __entry->len, (int)__entry->len, __get_dynamic_array(buf)
93 	    )
94 );
95 
96 #endif /* __BNO055_SERDEV_TRACE_H__ || TRACE_HEADER_MULTI_READ */
97 
98 #undef TRACE_INCLUDE_PATH
99 #define TRACE_INCLUDE_PATH .
100 #undef TRACE_INCLUDE_FILE
101 #define TRACE_INCLUDE_FILE bno055_ser_trace
102 
103 /* This part must be outside protection */
104 #include <trace/define_trace.h>
105