linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Eugen Hristev <eugen.hristev@microchip.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	<linux-iio@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] iio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw()
Date: Sat, 21 Jul 2018 19:07:43 +0100	[thread overview]
Message-ID: <20180721190743.370db592@archlinux> (raw)
In-Reply-To: <20180717081200.gxg6fxvzlgycudo5@M43218.corp.atmel.com>

On Tue, 17 Jul 2018 10:12:00 +0200
Ludovic Desroches <ludovic.desroches@microchip.com> wrote:

> On Mon, Jul 09, 2018 at 02:06:59PM +0300, Dan Carpenter wrote:
> > This code is problematic because we're supposed to be writing an int but
> > we instead write to only the high 16 bits.  This doesn't work on big
> > endian systems, and there is a potential that the bottom 16 bits are
> > used without being initialized.
> > 
> > Fixes: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >   
> 
> This patch sounds good and as it has been tested by Eugen:
> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
> 
> Thanks Dan and Eugen.

Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks

Jonathan

> 
> > diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> > index e02f7d1c86bc..d5ea84cf6460 100644
> > --- a/drivers/iio/adc/at91-sama5d2_adc.c
> > +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> > @@ -1296,6 +1296,7 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
> >  {
> >  	struct at91_adc_state *st = iio_priv(indio_dev);
> >  	u32 cor = 0;
> > +	u16 tmp_val;
> >  	int ret;
> >  
> >  	/*
> > @@ -1309,7 +1310,8 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
> >  		mutex_lock(&st->lock);
> >  
> >  		ret = at91_adc_read_position(st, chan->channel,
> > -					     (u16 *)val);
> > +					     &tmp_val);
> > +		*val = tmp_val;
> >  		mutex_unlock(&st->lock);
> >  		iio_device_release_direct_mode(indio_dev);
> >  
> > @@ -1322,7 +1324,8 @@ static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
> >  		mutex_lock(&st->lock);
> >  
> >  		ret = at91_adc_read_pressure(st, chan->channel,
> > -					     (u16 *)val);
> > +					     &tmp_val);
> > +		*val = tmp_val;
> >  		mutex_unlock(&st->lock);
> >  		iio_device_release_direct_mode(indio_dev);
> >  
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


      reply	other threads:[~2018-07-21 19:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 11:06 [PATCH] iio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw() Dan Carpenter
2018-07-09 11:22 ` Eugen Hristev
2018-07-09 11:41   ` Dan Carpenter
2018-07-15  8:15     ` Jonathan Cameron
2018-07-16 13:46       ` Eugen Hristev
2018-07-17  8:12 ` Ludovic Desroches
2018-07-21 18:07   ` 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=20180721190743.370db592@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=dan.carpenter@oracle.com \
    --cc=eugen.hristev@microchip.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=nicolas.ferre@microchip.com \
    --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;
as well as URLs for NNTP newsgroup(s).