All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Bárbara Fernandes" <barbara.fernandes@usp.br>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-usp@googlegroups.com
Subject: Re: [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s
Date: Sun, 3 Mar 2019 14:45:50 +0000	[thread overview]
Message-ID: <20190303144550.5a1b2039@archlinux> (raw)
In-Reply-To: <20190222203159.15116-4-barbara.fernandes@usp.br>

On Fri, 22 Feb 2019 17:31:58 -0300
Bárbara Fernandes <barbara.fernandes@usp.br> wrote:

> Put macro argument between parenthesis in order to avoid precedence
> issues. Solves the following checkpath.pl's messages:
> 
> CHECK: Macro argument 'mode' may be better as '(mode)' to avoid
> precedence issues
> CHECK: Macro argument 'channel' may be better as '(channel)' to
> avoid precedence issues
> CHECK: Macro argument reuse 'sequence' - possible side-effects?
> CHECK: Macro argument 'sequence' may be better as '(sequence)' to
> avoid precedence issues
> CHECK: Macro argument 'val' may be better as '(val)' to avoid
> precedence issues
> CHECK: Macro argument 'dec' may be better as '(dec)' to avoid precedence
> issues
> CHECK: Macro argument 'bits' may be better as '(bits)' to avoid
> precedence issues
> 
> Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Applied.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7923.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index b39ea834cdd6..dbece44e26e4 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -40,16 +40,16 @@
>  
>  #define AD7923_MAX_CHAN		4
>  
> -#define AD7923_PM_MODE_WRITE(mode)	(mode << 4)	/* write mode */
> -#define AD7923_CHANNEL_WRITE(channel)	(channel << 6)	/* write channel */
> -#define AD7923_SEQUENCE_WRITE(sequence)	(((sequence & 1) << 3) \
> -					+ ((sequence & 2) << 9))
> +#define AD7923_PM_MODE_WRITE(mode)	((mode) << 4)	 /* write mode */
> +#define AD7923_CHANNEL_WRITE(channel)	((channel) << 6) /* write channel */
> +#define AD7923_SEQUENCE_WRITE(sequence)	((((sequence) & 1) << 3) \
> +					+ (((sequence) & 2) << 9))
>  						/* write sequence fonction */
>  /* left shift for CR : bit 11 transmit in first */
>  #define AD7923_SHIFT_REGISTER	4
>  
>  /* val = value, dec = left shift, bits = number of bits of the mask */
> -#define EXTRACT(val, dec, bits)		((val >> dec) & ((1 << bits) - 1))
> +#define EXTRACT(val, dec, bits)		(((val) >> (dec)) & ((1 << (bits)) - 1))
>  
>  struct ad7923_state {
>  	struct spi_device		*spi;


  reply	other threads:[~2019-03-03 14:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
2019-03-03 14:43   ` Jonathan Cameron
2019-02-22 20:31 ` [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift Bárbara Fernandes
2019-03-03 14:44   ` Jonathan Cameron
2019-02-22 20:31 ` [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s Bárbara Fernandes
2019-03-03 14:45   ` Jonathan Cameron [this message]
2019-02-22 20:31 ` [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL Bárbara Fernandes
2019-03-03 14:47   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190303144550.5a1b2039@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=barbara.fernandes@usp.br \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.