lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131213131353.17d49ac4@gandalf.local.home>
Date:	Fri, 13 Dec 2013 13:13:53 -0500
From:	Steven Rostedt <rostedt@...dmis.org>
To:	David Howells <dhowells@...hat.com>
Cc:	Jean Delvare <khali@...ux-fr.org>, linux-i2c@...r.kernel.org,
	linux-kernel@...r.kernel.org, Wolfram Sang <wolfram@...-dreams.de>
Subject: Re: [PATCH] i2c: Add message transfer tracepoints for I2C and SMBUS

On Fri, 13 Dec 2013 17:26:53 +0000
David Howells <dhowells@...hat.com> 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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ