Linux IIO development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaya Durga <rjdurga@gmail.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
	lars@metafoo.de, Michael.Hennerich@analog.com,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	pmeerw@pmeerw.net, knaack.h@gmx.de, jic23@kernel.org
Subject: Re: [PATCH 3/3] Staging: iio: adc: ad7280a.c: Fixed Macro argument reuse
Date: Tue, 18 Jul 2017 13:01:26 +0300	[thread overview]
Message-ID: <20170718100126.4mxihfhkipcujsqm@mwanda> (raw)
In-Reply-To: <1500371272-16701-1-git-send-email-rjdurga@gmail.com>

On Tue, Jul 18, 2017 at 03:17:52PM +0530, Jaya Durga wrote:
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index d5ab83f..cb94b7f 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -99,9 +99,12 @@
>  #define AD7280A_DEVADDR_MASTER		0
>  #define AD7280A_DEVADDR_ALL		0x1F
>  /* 5-bit device address is sent LSB first */
> -#define AD7280A_DEVADDR(addr)	(((addr & 0x1) << 4) | ((addr & 0x2) << 3) | \
> -				(addr & 0x4) | ((addr & 0x8) >> 3) | \
> -				((addr & 0x10) >> 4))
> +static inline unsigned int AD7280A_DEVADDR(unsigned int addr)

Don't make this inline.  GCC is going to ignore the inline anyway, and
make up its own mind about what to do.  Change the name to not be all
caps.  Generally, all caps means it's a macro.

> +{
> +	return ((((addr & 0x1) << 4) | ((addr & 0x2) << 3) |
> +		  (addr & 0x4) | ((addr & 0x8) >> 3) |
> +		  ((addr & 0x10) >> 4)));

We don't need all the parens.

	return ((addr & 0x1) << 4) |
	       ((addr & 0x2) << 3) |
		(addr & 0x4)       |
	       ((addr & 0x8) >> 3) |
	       ((addr & 0x10) >> 4);

regards,
dan carpenter


      reply	other threads:[~2017-07-18 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18  9:47 [PATCH 3/3] Staging: iio: adc: ad7280a.c: Fixed Macro argument reuse Jaya Durga
2017-07-18 10:01 ` Dan Carpenter [this message]

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=20170718100126.4mxihfhkipcujsqm@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --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 \
    --cc=rjdurga@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox