linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] iio: ad7793: Fix the serial interface reset
@ 2017-09-05 12:16 Dragos Bogdan
  2017-09-05 12:17 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Dragos Bogdan @ 2017-09-05 12:16 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron
  Cc: Hartmut Knaack, Peter Meerwald-Stadler, linux-iio, linux-kernel,
	Dragos Bogdan

The serial interface can be reset by writing 32 consecutive 1s to the device.
'ret' was initialized correctly but its value was overwritten when
ad7793_check_platform_data() was called. Since a dedicated reset function
is present now, it should be used instead.

Fixes: 2edb769d246e ("iio:ad7793: Add support for the ad7798 and ad7799")
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
---
 drivers/iio/adc/ad7793.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index e6706a09e100..47c3d7f32900 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -257,7 +257,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
 	unsigned int vref_mv)
 {
 	struct ad7793_state *st = iio_priv(indio_dev);
-	int i, ret = -1;
+	int i, ret;
 	unsigned long long scale_uv;
 	u32 id;
 
@@ -266,7 +266,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
 		return ret;
 
 	/* reset the serial interface */
-	ret = spi_write(st->sd.spi, (u8 *)&ret, sizeof(ret));
+	ret = ad_sd_reset(&st->sd, 32);
 	if (ret < 0)
 		goto out;
 	usleep_range(500, 2000); /* Wait for at least 500us */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] iio: ad7793: Fix the serial interface reset
  2017-09-05 12:16 [PATCH 2/2] iio: ad7793: Fix the serial interface reset Dragos Bogdan
@ 2017-09-05 12:17 ` Lars-Peter Clausen
  2017-09-10 15:25   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2017-09-05 12:17 UTC (permalink / raw)
  To: Dragos Bogdan, Michael Hennerich, Jonathan Cameron
  Cc: Hartmut Knaack, Peter Meerwald-Stadler, linux-iio, linux-kernel

On 09/05/2017 02:16 PM, Dragos Bogdan wrote:
> The serial interface can be reset by writing 32 consecutive 1s to the device.
> 'ret' was initialized correctly but its value was overwritten when
> ad7793_check_platform_data() was called. Since a dedicated reset function
> is present now, it should be used instead.
> 
> Fixes: 2edb769d246e ("iio:ad7793: Add support for the ad7798 and ad7799")
> Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
>  drivers/iio/adc/ad7793.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> index e6706a09e100..47c3d7f32900 100644
> --- a/drivers/iio/adc/ad7793.c
> +++ b/drivers/iio/adc/ad7793.c
> @@ -257,7 +257,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
>  	unsigned int vref_mv)
>  {
>  	struct ad7793_state *st = iio_priv(indio_dev);
> -	int i, ret = -1;
> +	int i, ret;
>  	unsigned long long scale_uv;
>  	u32 id;
>  
> @@ -266,7 +266,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
>  		return ret;
>  
>  	/* reset the serial interface */
> -	ret = spi_write(st->sd.spi, (u8 *)&ret, sizeof(ret));
> +	ret = ad_sd_reset(&st->sd, 32);
>  	if (ret < 0)
>  		goto out;
>  	usleep_range(500, 2000); /* Wait for at least 500us */
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] iio: ad7793: Fix the serial interface reset
  2017-09-05 12:17 ` Lars-Peter Clausen
@ 2017-09-10 15:25   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2017-09-10 15:25 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Dragos Bogdan, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

On Tue, 5 Sep 2017 14:17:21 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:

> On 09/05/2017 02:16 PM, Dragos Bogdan wrote:
> > The serial interface can be reset by writing 32 consecutive 1s to the device.
> > 'ret' was initialized correctly but its value was overwritten when
> > ad7793_check_platform_data() was called. Since a dedicated reset function
> > is present now, it should be used instead.
> > 
> > Fixes: 2edb769d246e ("iio:ad7793: Add support for the ad7798 and ad7799")
> > Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>  
> 
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>

Applied to the fixes-togreg branch of iio.git and marked
for stable.

Thanks

Jonathan
> 
> > ---
> >  drivers/iio/adc/ad7793.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> > index e6706a09e100..47c3d7f32900 100644
> > --- a/drivers/iio/adc/ad7793.c
> > +++ b/drivers/iio/adc/ad7793.c
> > @@ -257,7 +257,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
> >  	unsigned int vref_mv)
> >  {
> >  	struct ad7793_state *st = iio_priv(indio_dev);
> > -	int i, ret = -1;
> > +	int i, ret;
> >  	unsigned long long scale_uv;
> >  	u32 id;
> >  
> > @@ -266,7 +266,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
> >  		return ret;
> >  
> >  	/* reset the serial interface */
> > -	ret = spi_write(st->sd.spi, (u8 *)&ret, sizeof(ret));
> > +	ret = ad_sd_reset(&st->sd, 32);
> >  	if (ret < 0)
> >  		goto out;
> >  	usleep_range(500, 2000); /* Wait for at least 500us */
> >   
> 
> --
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-10 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-05 12:16 [PATCH 2/2] iio: ad7793: Fix the serial interface reset Dragos Bogdan
2017-09-05 12:17 ` Lars-Peter Clausen
2017-09-10 15:25   ` Jonathan Cameron

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).