1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* I2C message transfer tracepoints 2 /* I2C message transfer tracepoints 3 * 3 * 4 * Copyright (C) 2013 Red Hat, Inc. All Rights 4 * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved. 5 * Written by David Howells (dhowells@redhat.c 5 * Written by David Howells (dhowells@redhat.com) 6 */ 6 */ 7 #undef TRACE_SYSTEM 7 #undef TRACE_SYSTEM 8 #define TRACE_SYSTEM i2c 8 #define TRACE_SYSTEM i2c 9 9 10 #if !defined(_TRACE_I2C_H) || defined(TRACE_HE 10 #if !defined(_TRACE_I2C_H) || defined(TRACE_HEADER_MULTI_READ) 11 #define _TRACE_I2C_H 11 #define _TRACE_I2C_H 12 12 13 #include <linux/i2c.h> 13 #include <linux/i2c.h> 14 #include <linux/tracepoint.h> 14 #include <linux/tracepoint.h> 15 15 16 /* 16 /* 17 * drivers/i2c/i2c-core-base.c 17 * drivers/i2c/i2c-core-base.c 18 */ 18 */ 19 extern int i2c_transfer_trace_reg(void); 19 extern int i2c_transfer_trace_reg(void); 20 extern void i2c_transfer_trace_unreg(void); 20 extern void i2c_transfer_trace_unreg(void); 21 21 22 /* 22 /* 23 * __i2c_transfer() write request 23 * __i2c_transfer() write request 24 */ 24 */ 25 TRACE_EVENT_FN(i2c_write, 25 TRACE_EVENT_FN(i2c_write, 26 TP_PROTO(const struct i2c_adapt 26 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, 27 int num), 27 int num), 28 TP_ARGS(adap, msg, num), 28 TP_ARGS(adap, msg, num), 29 TP_STRUCT__entry( 29 TP_STRUCT__entry( 30 __field(int, adapte 30 __field(int, adapter_nr ) 31 __field(__u16, msg_nr 31 __field(__u16, msg_nr ) 32 __field(__u16, addr 32 __field(__u16, addr ) 33 __field(__u16, flags 33 __field(__u16, flags ) 34 __field(__u16, len 34 __field(__u16, len ) 35 __dynamic_array(__u8, b 35 __dynamic_array(__u8, buf, msg->len) ), 36 TP_fast_assign( 36 TP_fast_assign( 37 __entry->adapter_nr = a 37 __entry->adapter_nr = adap->nr; 38 __entry->msg_nr = num; 38 __entry->msg_nr = num; 39 __entry->addr = msg->ad 39 __entry->addr = msg->addr; 40 __entry->flags = msg->f 40 __entry->flags = msg->flags; 41 __entry->len = msg->len 41 __entry->len = msg->len; 42 memcpy(__get_dynamic_ar 42 memcpy(__get_dynamic_array(buf), msg->buf, msg->len); 43 ), 43 ), 44 TP_printk("i2c-%d #%u a=%03x f= 44 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]", 45 __entry->adapter_nr, 45 __entry->adapter_nr, 46 __entry->msg_nr, 46 __entry->msg_nr, 47 __entry->addr, 47 __entry->addr, 48 __entry->flags, 48 __entry->flags, 49 __entry->len, 49 __entry->len, 50 __entry->len, __get_d 50 __entry->len, __get_dynamic_array(buf) 51 ), 51 ), 52 i2c_transfer_trace_reg, 52 i2c_transfer_trace_reg, 53 i2c_transfer_trace_unreg); 53 i2c_transfer_trace_unreg); 54 54 55 /* 55 /* 56 * __i2c_transfer() read request 56 * __i2c_transfer() read request 57 */ 57 */ 58 TRACE_EVENT_FN(i2c_read, 58 TRACE_EVENT_FN(i2c_read, 59 TP_PROTO(const struct i2c_adapt 59 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, 60 int num), 60 int num), 61 TP_ARGS(adap, msg, num), 61 TP_ARGS(adap, msg, num), 62 TP_STRUCT__entry( 62 TP_STRUCT__entry( 63 __field(int, adapte 63 __field(int, adapter_nr ) 64 __field(__u16, msg_nr 64 __field(__u16, msg_nr ) 65 __field(__u16, addr 65 __field(__u16, addr ) 66 __field(__u16, flags 66 __field(__u16, flags ) 67 __field(__u16, len 67 __field(__u16, len ) 68 ), 68 ), 69 TP_fast_assign( 69 TP_fast_assign( 70 __entry->adapter_nr = a 70 __entry->adapter_nr = adap->nr; 71 __entry->msg_nr = num; 71 __entry->msg_nr = num; 72 __entry->addr = msg->ad 72 __entry->addr = msg->addr; 73 __entry->flags = msg->f 73 __entry->flags = msg->flags; 74 __entry->len = msg->len 74 __entry->len = msg->len; 75 ), 75 ), 76 TP_printk("i2c-%d #%u a=%03x f= 76 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u", 77 __entry->adapter_nr, 77 __entry->adapter_nr, 78 __entry->msg_nr, 78 __entry->msg_nr, 79 __entry->addr, 79 __entry->addr, 80 __entry->flags, 80 __entry->flags, 81 __entry->len 81 __entry->len 82 ), 82 ), 83 i2c_transfer_trace_reg, 83 i2c_transfer_trace_reg, 84 i2c_transfer_trace_unre 84 i2c_transfer_trace_unreg); 85 85 86 /* 86 /* 87 * __i2c_transfer() read reply 87 * __i2c_transfer() read reply 88 */ 88 */ 89 TRACE_EVENT_FN(i2c_reply, 89 TRACE_EVENT_FN(i2c_reply, 90 TP_PROTO(const struct i2c_adapt 90 TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, 91 int num), 91 int num), 92 TP_ARGS(adap, msg, num), 92 TP_ARGS(adap, msg, num), 93 TP_STRUCT__entry( 93 TP_STRUCT__entry( 94 __field(int, adapte 94 __field(int, adapter_nr ) 95 __field(__u16, msg_nr 95 __field(__u16, msg_nr ) 96 __field(__u16, addr 96 __field(__u16, addr ) 97 __field(__u16, flags 97 __field(__u16, flags ) 98 __field(__u16, len 98 __field(__u16, len ) 99 __dynamic_array(__u8, b 99 __dynamic_array(__u8, buf, msg->len) ), 100 TP_fast_assign( 100 TP_fast_assign( 101 __entry->adapter_nr = a 101 __entry->adapter_nr = adap->nr; 102 __entry->msg_nr = num; 102 __entry->msg_nr = num; 103 __entry->addr = msg->ad 103 __entry->addr = msg->addr; 104 __entry->flags = msg->f 104 __entry->flags = msg->flags; 105 __entry->len = msg->len 105 __entry->len = msg->len; 106 memcpy(__get_dynamic_ar 106 memcpy(__get_dynamic_array(buf), msg->buf, msg->len); 107 ), 107 ), 108 TP_printk("i2c-%d #%u a=%03x f= 108 TP_printk("i2c-%d #%u a=%03x f=%04x l=%u [%*phD]", 109 __entry->adapter_nr, 109 __entry->adapter_nr, 110 __entry->msg_nr, 110 __entry->msg_nr, 111 __entry->addr, 111 __entry->addr, 112 __entry->flags, 112 __entry->flags, 113 __entry->len, 113 __entry->len, 114 __entry->len, __get_d 114 __entry->len, __get_dynamic_array(buf) 115 ), 115 ), 116 i2c_transfer_trace_reg, 116 i2c_transfer_trace_reg, 117 i2c_transfer_trace_unreg); 117 i2c_transfer_trace_unreg); 118 118 119 /* 119 /* 120 * __i2c_transfer() result 120 * __i2c_transfer() result 121 */ 121 */ 122 TRACE_EVENT_FN(i2c_result, 122 TRACE_EVENT_FN(i2c_result, 123 TP_PROTO(const struct i2c_adapt 123 TP_PROTO(const struct i2c_adapter *adap, int num, int ret), 124 TP_ARGS(adap, num, ret), 124 TP_ARGS(adap, num, ret), 125 TP_STRUCT__entry( 125 TP_STRUCT__entry( 126 __field(int, adapte 126 __field(int, adapter_nr ) 127 __field(__u16, nr_msg 127 __field(__u16, nr_msgs ) 128 __field(__s16, ret 128 __field(__s16, ret ) 129 ), 129 ), 130 TP_fast_assign( 130 TP_fast_assign( 131 __entry->adapter_nr = a 131 __entry->adapter_nr = adap->nr; 132 __entry->nr_msgs = num; 132 __entry->nr_msgs = num; 133 __entry->ret = ret; 133 __entry->ret = ret; 134 ), 134 ), 135 TP_printk("i2c-%d n=%u ret=%d", 135 TP_printk("i2c-%d n=%u ret=%d", 136 __entry->adapter_nr, 136 __entry->adapter_nr, 137 __entry->nr_msgs, 137 __entry->nr_msgs, 138 __entry->ret 138 __entry->ret 139 ), 139 ), 140 i2c_transfer_trace_reg, 140 i2c_transfer_trace_reg, 141 i2c_transfer_trace_unreg); 141 i2c_transfer_trace_unreg); 142 142 143 #endif /* _TRACE_I2C_H */ 143 #endif /* _TRACE_I2C_H */ 144 144 145 /* This part must be outside protection */ 145 /* This part must be outside protection */ 146 #include <trace/define_trace.h> 146 #include <trace/define_trace.h> 147 147
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.