public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH v1] iio: adc: intel_mrfld_adc: Use be16_to_cpu() instead of get_unaligned_be16()
Date: Sun, 15 Mar 2020 13:08:29 +0000	[thread overview]
Message-ID: <20200315130829.45790821@archlinux> (raw)
In-Reply-To: <20200311092223.9673-1-andriy.shevchenko@linux.intel.com>

On Wed, 11 Mar 2020 11:22:23 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> There is no need to call unaligned helpers on stack placed variables
> because compiler will align them correctly, accordingly to architectural
> ABI. Moreover, using bitwise type makes it explicit to see what we are
> reading in bulk transfer. On top of that, use sizeof() instead of
> magic value.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/intel_mrfld_adc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c
> index c35a1beb817c..a6d2e1f27e76 100644
> --- a/drivers/iio/adc/intel_mrfld_adc.c
> +++ b/drivers/iio/adc/intel_mrfld_adc.c
> @@ -75,7 +75,7 @@ static int mrfld_adc_single_conv(struct iio_dev *indio_dev,
>  	struct regmap *regmap = adc->regmap;
>  	unsigned int req;
>  	long timeout;
> -	u8 buf[2];
> +	__be16 value;
>  	int ret;
>  
>  	reinit_completion(&adc->completion);
> @@ -105,11 +105,11 @@ static int mrfld_adc_single_conv(struct iio_dev *indio_dev,
>  		goto done;
>  	}
>  
> -	ret = regmap_bulk_read(regmap, chan->address, buf, 2);
> +	ret = regmap_bulk_read(regmap, chan->address, &value, sizeof(value));
>  	if (ret)
>  		goto done;
>  
> -	*result = get_unaligned_be16(buf);
> +	*result = be16_to_cpu(value);
>  	ret = IIO_VAL_INT;
>  
>  done:


      reply	other threads:[~2020-03-15 13:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11  9:22 [PATCH v1] iio: adc: intel_mrfld_adc: Use be16_to_cpu() instead of get_unaligned_be16() Andy Shevchenko
2020-03-15 13:08 ` Jonathan Cameron [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=20200315130829.45790821@archlinux \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox