public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: iio: adis16203: Use devm_iio_device_register
@ 2014-07-17 20:40 Himangi Saraogi
  2014-07-17 20:47 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Himangi Saraogi @ 2014-07-17 20:40 UTC (permalink / raw)
  To: Jonathan Cameron, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel
  Cc: julia.lawall

This patch introduces the use of iio_device_register and does away with
the call to the corressponding unregister function in the probe and
remove functions of the driver respectively.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/staging/iio/accel/adis16203_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c
index 409a28e..5077779 100644
--- a/drivers/staging/iio/accel/adis16203_core.c
+++ b/drivers/staging/iio/accel/adis16203_core.c
@@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)
 	if (ret)
 		goto error_cleanup_buffer_trigger;
 
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(&spi->dev, indio_dev);
 	if (ret)
 		goto error_cleanup_buffer_trigger;
 
@@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)
 	struct iio_dev *indio_dev = spi_get_drvdata(spi);
 	struct adis *st = iio_priv(indio_dev);
 
-	iio_device_unregister(indio_dev);
 	adis_cleanup_buffer_and_trigger(st, indio_dev);
 
 	return 0;
-- 
1.9.1


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

* Re: [PATCH] staging: iio: adis16203: Use devm_iio_device_register
  2014-07-17 20:40 [PATCH] staging: iio: adis16203: Use devm_iio_device_register Himangi Saraogi
@ 2014-07-17 20:47 ` Lars-Peter Clausen
  2014-07-17 21:08   ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2014-07-17 20:47 UTC (permalink / raw)
  To: Himangi Saraogi, Jonathan Cameron, Greg Kroah-Hartman, linux-iio,
	devel, linux-kernel
  Cc: julia.lawall

On 07/17/2014 10:40 PM, Himangi Saraogi wrote:
> This patch introduces the use of iio_device_register and does away with
> the call to the corressponding unregister function in the probe and
> remove functions of the driver respectively.
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

No, you changed the relative order in which iio_device_unregister() and 
adis_cleanup_buffer_and_trigger() are called, this opens up the way for race 
conditions. Rule of thumb: Don't convert drivers to managed functions if 
this will change the order in which functions will called on device removal.

- Lars

> ---
>   drivers/staging/iio/accel/adis16203_core.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c
> index 409a28e..5077779 100644
> --- a/drivers/staging/iio/accel/adis16203_core.c
> +++ b/drivers/staging/iio/accel/adis16203_core.c
> @@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)
>   	if (ret)
>   		goto error_cleanup_buffer_trigger;
>
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_iio_device_register(&spi->dev, indio_dev);
>   	if (ret)
>   		goto error_cleanup_buffer_trigger;
>
> @@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)
>   	struct iio_dev *indio_dev = spi_get_drvdata(spi);
>   	struct adis *st = iio_priv(indio_dev);
>
> -	iio_device_unregister(indio_dev);
>   	adis_cleanup_buffer_and_trigger(st, indio_dev);
>
>   	return 0;
>


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

* Re: [PATCH] staging: iio: adis16203: Use devm_iio_device_register
  2014-07-17 20:47 ` Lars-Peter Clausen
@ 2014-07-17 21:08   ` Julia Lawall
  0 siblings, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2014-07-17 21:08 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: Himangi Saraogi, Jonathan Cameron, Greg Kroah-Hartman, linux-iio,
	devel, linux-kernel



On Thu, 17 Jul 2014, Lars-Peter Clausen wrote:

> On 07/17/2014 10:40 PM, Himangi Saraogi wrote:
> > This patch introduces the use of iio_device_register and does away with
> > the call to the corressponding unregister function in the probe and
> > remove functions of the driver respectively.
> > 
> > Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> > Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> 
> No, you changed the relative order in which iio_device_unregister() and
> adis_cleanup_buffer_and_trigger() are called, this opens up the way for race
> conditions. Rule of thumb: Don't convert drivers to managed functions if this
> will change the order in which functions will called on device removal.

Thanks for the information.  I was indeed not sure about this.

Unfortunately, removal code is not always perfectly written, and the 
operations are not always done in the right order...

julia

> - Lars
> 
> > ---
> >   drivers/staging/iio/accel/adis16203_core.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/accel/adis16203_core.c
> > b/drivers/staging/iio/accel/adis16203_core.c
> > index 409a28e..5077779 100644
> > --- a/drivers/staging/iio/accel/adis16203_core.c
> > +++ b/drivers/staging/iio/accel/adis16203_core.c
> > @@ -175,7 +175,7 @@ static int adis16203_probe(struct spi_device *spi)
> >   	if (ret)
> >   		goto error_cleanup_buffer_trigger;
> > 
> > -	ret = iio_device_register(indio_dev);
> > +	ret = devm_iio_device_register(&spi->dev, indio_dev);
> >   	if (ret)
> >   		goto error_cleanup_buffer_trigger;
> > 
> > @@ -191,7 +191,6 @@ static int adis16203_remove(struct spi_device *spi)
> >   	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >   	struct adis *st = iio_priv(indio_dev);
> > 
> > -	iio_device_unregister(indio_dev);
> >   	adis_cleanup_buffer_and_trigger(st, indio_dev);
> > 
> >   	return 0;
> > 
> 
> 

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

end of thread, other threads:[~2014-07-17 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17 20:40 [PATCH] staging: iio: adis16203: Use devm_iio_device_register Himangi Saraogi
2014-07-17 20:47 ` Lars-Peter Clausen
2014-07-17 21:08   ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox