All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: amplifiers: ad8366: move channel init before iio_device_register()
@ 2018-05-21  6:40 Alexandru Ardelean
  2018-05-21 15:10 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2018-05-21  6:40 UTC (permalink / raw)
  To: linux-iio; +Cc: Michael.Hennerich, Lars-Peter.Clausen, Alexandru Ardelean

Otherwise a race condition can occur, where userspace can start operations
before the channels have been properly initialized.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/amplifiers/ad8366.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 43667866321e..0138337aedd1 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -161,12 +161,14 @@ static int ad8366_probe(struct spi_device *spi)
 	indio_dev->channels = ad8366_channels;
 	indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
 
+	ret = ad8366_write(indio_dev, 0 , 0);
+	if (ret < 0)
+		goto error_disable_reg;
+
 	ret = iio_device_register(indio_dev);
 	if (ret)
 		goto error_disable_reg;
 
-	ad8366_write(indio_dev, 0, 0);
-
 	return 0;
 
 error_disable_reg:
-- 
2.17.0


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

* Re: [PATCH] iio: amplifiers: ad8366: move channel init before iio_device_register()
  2018-05-21  6:40 [PATCH] iio: amplifiers: ad8366: move channel init before iio_device_register() Alexandru Ardelean
@ 2018-05-21 15:10 ` Lars-Peter Clausen
  2018-05-22 17:16   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2018-05-21 15:10 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-iio; +Cc: Michael.Hennerich

Patch looks good, but remember to put the maintainer and reviewers on the
recipient list. Otherwise there is a risk that the patch gets lost.

On 05/21/2018 08:40 AM, Alexandru Ardelean wrote:
> Otherwise a race condition can occur, where userspace can start operations
> before the channels have been properly initialized.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  drivers/iio/amplifiers/ad8366.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 43667866321e..0138337aedd1 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -161,12 +161,14 @@ static int ad8366_probe(struct spi_device *spi)
>  	indio_dev->channels = ad8366_channels;
>  	indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
>  
> +	ret = ad8366_write(indio_dev, 0 , 0);
> +	if (ret < 0)
> +		goto error_disable_reg;
> +
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
>  		goto error_disable_reg;
>  
> -	ad8366_write(indio_dev, 0, 0);
> -
>  	return 0;
>  
>  error_disable_reg:
> 


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

* Re: [PATCH] iio: amplifiers: ad8366: move channel init before iio_device_register()
  2018-05-21 15:10 ` Lars-Peter Clausen
@ 2018-05-22 17:16   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2018-05-22 17:16 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Alexandru Ardelean, linux-iio, Michael.Hennerich

On Mon, 21 May 2018 17:10:00 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:

> Patch looks good, but remember to put the maintainer and reviewers on the
> recipient list. Otherwise there is a risk that the patch gets lost.
> 
> On 05/21/2018 08:40 AM, Alexandru Ardelean wrote:
> > Otherwise a race condition can occur, where userspace can start operations
> > before the channels have been properly initialized.
> > 
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.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/amplifiers/ad8366.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> > index 43667866321e..0138337aedd1 100644
> > --- a/drivers/iio/amplifiers/ad8366.c
> > +++ b/drivers/iio/amplifiers/ad8366.c
> > @@ -161,12 +161,14 @@ static int ad8366_probe(struct spi_device *spi)
> >  	indio_dev->channels = ad8366_channels;
> >  	indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
> >  
> > +	ret = ad8366_write(indio_dev, 0 , 0);
> > +	if (ret < 0)
> > +		goto error_disable_reg;
> > +
> >  	ret = iio_device_register(indio_dev);
> >  	if (ret)
> >  		goto error_disable_reg;
> >  
> > -	ad8366_write(indio_dev, 0, 0);
> > -
> >  	return 0;
> >  
> >  error_disable_reg:
> >   
> 
> --
> 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:[~2018-05-22 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-21  6:40 [PATCH] iio: amplifiers: ad8366: move channel init before iio_device_register() Alexandru Ardelean
2018-05-21 15:10 ` Lars-Peter Clausen
2018-05-22 17:16   ` Jonathan Cameron

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.