linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register
@ 2014-02-01 14:39 Johannes Thumshirn
  2014-02-01 14:46 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2014-02-01 14:39 UTC (permalink / raw)
  To: Jonathan Cameron, Sachin Kamat, Peter Meerwald
  Cc: ohannes Thumshirn, linux-iio, linux-kernel

Call platform_set_drvdata before devm_iio_device_register to avoid possible
race condition when accessing driver data.

Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
---
 drivers/iio/adc/viperboard_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
index d0add8f..7d9bd05 100644
--- a/drivers/iio/adc/viperboard_adc.c
+++ b/drivers/iio/adc/viperboard_adc.c
@@ -133,14 +133,14 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
 	indio_dev->channels = vprbrd_adc_iio_channels;
 	indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels);
 
+	platform_set_drvdata(pdev, indio_dev);
+
 	ret = devm_iio_device_register(&pdev->dev, indio_dev);
 	if (ret) {
 		dev_err(&pdev->dev, "could not register iio (adc)");
 		return ret;
 	}
 
-	platform_set_drvdata(pdev, indio_dev);
-
 	return 0;
 }
 
-- 
1.8.5.3


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

* Re: [PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register
  2014-02-01 14:39 [PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register Johannes Thumshirn
@ 2014-02-01 14:46 ` Lars-Peter Clausen
  2014-02-01 14:49   ` Johannes Thumshirn
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2014-02-01 14:46 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Jonathan Cameron, Sachin Kamat, Peter Meerwald, linux-iio, linux-kernel

On 02/01/2014 03:39 PM, Johannes Thumshirn wrote:
> Call platform_set_drvdata before devm_iio_device_register to avoid possible
> race condition when accessing driver data.

I don't think the driver data is accessed from within any of the IIO device
callbacks. In fact I don't think it is accessed at all with the latest
conversion to devm_iio_device_register(). So I think the call to
platform_set_drvdata can just be removed.

> 
> Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
> ---
>  drivers/iio/adc/viperboard_adc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
> index d0add8f..7d9bd05 100644
> --- a/drivers/iio/adc/viperboard_adc.c
> +++ b/drivers/iio/adc/viperboard_adc.c
> @@ -133,14 +133,14 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
>  	indio_dev->channels = vprbrd_adc_iio_channels;
>  	indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels);
>  
> +	platform_set_drvdata(pdev, indio_dev);
> +
>  	ret = devm_iio_device_register(&pdev->dev, indio_dev);
>  	if (ret) {
>  		dev_err(&pdev->dev, "could not register iio (adc)");
>  		return ret;
>  	}
>  
> -	platform_set_drvdata(pdev, indio_dev);
> -
>  	return 0;
>  }
>  
> 


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

* Re: [PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register
  2014-02-01 14:46 ` Lars-Peter Clausen
@ 2014-02-01 14:49   ` Johannes Thumshirn
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2014-02-01 14:49 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Jonathan Cameron, Sachin Kamat, Peter Meerwald, linux-iio, linux-kernel

On Sat, Feb 01, 2014 at 03:46:05PM +0100, Lars-Peter Clausen wrote:
> On 02/01/2014 03:39 PM, Johannes Thumshirn wrote:
> > Call platform_set_drvdata before devm_iio_device_register to avoid possible
> > race condition when accessing driver data.
>
> I don't think the driver data is accessed from within any of the IIO device
> callbacks. In fact I don't think it is accessed at all with the latest
> conversion to devm_iio_device_register(). So I think the call to
> platform_set_drvdata can just be removed.
>
> >
> > Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
> > ---
> >  drivers/iio/adc/viperboard_adc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
> > index d0add8f..7d9bd05 100644
> > --- a/drivers/iio/adc/viperboard_adc.c
> > +++ b/drivers/iio/adc/viperboard_adc.c
> > @@ -133,14 +133,14 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
> >  	indio_dev->channels = vprbrd_adc_iio_channels;
> >  	indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels);
> >
> > +	platform_set_drvdata(pdev, indio_dev);
> > +
> >  	ret = devm_iio_device_register(&pdev->dev, indio_dev);
> >  	if (ret) {
> >  		dev_err(&pdev->dev, "could not register iio (adc)");
> >  		return ret;
> >  	}
> >
> > -	platform_set_drvdata(pdev, indio_dev);
> > -
> >  	return 0;
> >  }
> >
> >
>

Looks like you're right. So we can drop this patch and I'll make a remove version.

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

end of thread, other threads:[~2014-02-01 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-01 14:39 [PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register Johannes Thumshirn
2014-02-01 14:46 ` Lars-Peter Clausen
2014-02-01 14:49   ` Johannes Thumshirn

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