linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 10/10] iio: light: rpr0521 iio_device_register to devm_
@ 2017-06-15  8:55 Mikko Koivunen
  2017-06-20 17:10 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Mikko Koivunen @ 2017-06-15  8:55 UTC (permalink / raw)
  To: jic23; +Cc: pmeerw, knaack.h, lars, Daniel Baluta, linux-iio, Mikko Koivunen

Change iio_device_register to devm_

Signed-off-by: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
---

 drivers/iio/light/rpr0521.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
index ce576be..e00f427 100644
--- a/drivers/iio/light/rpr0521.c
+++ b/drivers/iio/light/rpr0521.c
@@ -1025,7 +1025,7 @@ static int rpr0521_probe(struct i2c_client *client,
 		}
 	}
 
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
 	if (ret)
 		goto err_pm_disable;
 
@@ -1045,8 +1045,6 @@ static int rpr0521_remove(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-	iio_device_unregister(indio_dev);
-
 	pm_runtime_disable(&client->dev);
 	pm_runtime_set_suspended(&client->dev);
 	pm_runtime_put_noidle(&client->dev);
-- 
1.7.9.5

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

* Re: [PATCH v6 10/10] iio: light: rpr0521 iio_device_register to devm_
  2017-06-15  8:55 [PATCH v6 10/10] iio: light: rpr0521 iio_device_register to devm_ Mikko Koivunen
@ 2017-06-20 17:10 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2017-06-20 17:10 UTC (permalink / raw)
  To: Mikko Koivunen; +Cc: pmeerw, knaack.h, lars, Daniel Baluta, linux-iio

On Thu, 15 Jun 2017 11:55:47 +0300
Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com> wrote:

> Change iio_device_register to devm_
> 
> Signed-off-by: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
This leads to a race I think.
Power is turned off in remove.  Userspace interface is only removed
after the remove call ends.

Basic rule of thumb is that if you have anything in .remove then
you can't use the devm_iio_device_register call.

Jonathan
> ---
> 
>  drivers/iio/light/rpr0521.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
> index ce576be..e00f427 100644
> --- a/drivers/iio/light/rpr0521.c
> +++ b/drivers/iio/light/rpr0521.c
> @@ -1025,7 +1025,7 @@ static int rpr0521_probe(struct i2c_client *client,
>  		}
>  	}
>  
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
>  	if (ret)
>  		goto err_pm_disable;
>  
> @@ -1045,8 +1045,6 @@ static int rpr0521_remove(struct i2c_client *client)
>  {
>  	struct iio_dev *indio_dev = i2c_get_clientdata(client);
>  
> -	iio_device_unregister(indio_dev);
> -
>  	pm_runtime_disable(&client->dev);
>  	pm_runtime_set_suspended(&client->dev);
>  	pm_runtime_put_noidle(&client->dev);


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

end of thread, other threads:[~2017-06-20 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-15  8:55 [PATCH v6 10/10] iio: light: rpr0521 iio_device_register to devm_ Mikko Koivunen
2017-06-20 17:10 ` 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).