On Fri, 13 Dec 2013 17:26:53 +0000 David Howells <dhowells@xxxxxxxxxx> wrote: > index ed366e145c8d..ca19f4948290 100644 > --- a/include/trace/events/i2c.h > +++ b/include/trace/events/i2c.h > @@ -23,42 +23,259 @@ > extern void i2c_transfer_trace_reg(void); > extern void i2c_transfer_trace_unreg(void); > > -TRACE_EVENT_FN(i2c_transfer, > +/* > + * __i2c_transfer() write request > + */ > +TRACE_EVENT_FN(i2c_write, > TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, > - int ret), > - TP_ARGS(adap, msg, ret), > + int num), > + TP_ARGS(adap, msg, num), > TP_STRUCT__entry( > - __field( int, adapter_nr ) > + __field(int, adapter_nr ) > + __field(__u16, msg_nr ) > __field(__u16, addr ) > __field(__u16, flags ) > __field(__u16, len ) > - __field(__s16, ret ) > __dynamic_array(__u8, buf, msg->len) ), > TP_fast_assign( > __entry->adapter_nr = adap->nr; > + __entry->msg_nr = num; > + __entry->addr = msg->addr; > + __entry->flags = msg->flags; > + __entry->len = msg->len; > + memcpy(__get_dynamic_array(buf), msg->buf, msg->len); > + ), > + TP_printk("i2c-%d #%u f=%02x a=%02x l=%u [%*phN]", > + __entry->adapter_nr, > + __entry->msg_nr, > + __entry->flags, > + __entry->addr, > + __entry->len, > + __entry->len, __get_dynamic_array(buf) > + ), > + i2c_transfer_trace_reg, > + i2c_transfer_trace_unreg); > + > +/* > + * __i2c_transfer() read request > + */ > +TRACE_EVENT_FN(i2c_read, > + TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, > + int num), > + TP_ARGS(adap, msg, num), > + TP_STRUCT__entry( > + __field(int, adapter_nr ) > + __field(__u16, msg_nr ) > + __field(__u16, addr ) > + __field(__u16, flags ) > + __field(__u16, len ) > + ), > + TP_fast_assign( > + __entry->adapter_nr = adap->nr; > + __entry->msg_nr = num; > + __entry->addr = msg->addr; > + __entry->flags = msg->flags; > + __entry->len = msg->len; > + ), > + TP_printk("i2c-%d #%u f=%02x a=%02x l=%u", > + __entry->adapter_nr, > + __entry->msg_nr, > + __entry->flags, > + __entry->addr, > + __entry->len > + ), > + i2c_transfer_trace_reg, > + i2c_transfer_trace_unreg); > + Now that you have two tracepoints that are identical, you can use DECLARE_EVENT_CLASS() and DEFINE_EVENT_FN(). That is: DECLARE_EVENT_CLASS(i2c_read_write, TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg, int num), TP_ARGS(adap, msg, num), TP_STRUCT__entry( __field(int, adapter_nr ) __field(__u16, msg_nr ) __field(__u16, addr ) __field(__u16, flags ) __field(__u16, len )), TP_fast_assign( __entry->adapter_nr = adap->nr; __entry->msg_nr = num; __entry->addr = msg->addr; __entry->flags = msg->flags; __entry->len = msg->len; ), TP_printk("i2c-%d #%u f=%02x a=%02x l=%u", __entry->adapter_nr, __entry->msg_nr, __entry->flags, __entry->addr, __entry->len ) ); DEFINE_EVENT_FN(i2c_read_write, i2c_read, TP_PROTO(const struct i2c_adapter *adap, const struct i2c_ msg *msg, int num), TP_ARGS(adap, msg, num), i2c_transfer_trace_reg, i2c_transfer_trace_unreg); DEFINE_EVENT_FN(i2c_read_write, i2c_write, TP_PROTO(const struct i2c_adapter *adap, const struct i2c_ msg *msg, int num), TP_ARGS(adap, msg, num), i2c_transfer_trace_reg, i2c_transfer_trace_unreg); This will reduce duplication of code by several kilobytes. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html