diff mbox series

[09/28] iio: imu: kmx61: Balance runtime pm + use pm_runtime_resume_and_get()

Message ID 20210509113354.660190-10-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series IIO: Runtime PM related cleanups. | expand

Commit Message

Jonathan Cameron May 9, 2021, 11:33 a.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

No point in calling pm_runtime_put_noidle() that isn't balancing a get.
Note no actual impact because the runtime pm core protects against
a negative reference counter.

For the pm_runtime_resume_and_get() main interest is in clearing
out this old pattern to avoid it getting coppied into new submissions.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/imu/kmx61.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Mauro Carvalho Chehab May 12, 2021, 1:45 p.m. UTC | #1
Em Sun,  9 May 2021 12:33:35 +0100
Jonathan Cameron <jic23@kernel.org> escreveu:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> No point in calling pm_runtime_put_noidle() that isn't balancing a get.
> Note no actual impact because the runtime pm core protects against
> a negative reference counter.
> 
> For the pm_runtime_resume_and_get() main interest is in clearing
> out this old pattern to avoid it getting coppied into new submissions.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

LGTM.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

> ---
>  drivers/iio/imu/kmx61.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
> index d3e06ce99c1e..1dabfd615dab 100644
> --- a/drivers/iio/imu/kmx61.c
> +++ b/drivers/iio/imu/kmx61.c
> @@ -750,7 +750,7 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
>  	}
>  
>  	if (on) {
> -		ret = pm_runtime_get_sync(&data->client->dev);
> +		ret = pm_runtime_resume_and_get(&data->client->dev);
>  	} else {
>  		pm_runtime_mark_last_busy(&data->client->dev);
>  		ret = pm_runtime_put_autosuspend(&data->client->dev);
> @@ -759,8 +759,6 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
>  		dev_err(&data->client->dev,
>  			"Failed: kmx61_set_power_state for %d, ret %d\n",
>  			on, ret);
> -		if (on)
> -			pm_runtime_put_noidle(&data->client->dev);
>  
>  		return ret;
>  	}
> @@ -1426,7 +1424,6 @@ static int kmx61_remove(struct i2c_client *client)
>  
>  	pm_runtime_disable(&client->dev);
>  	pm_runtime_set_suspended(&client->dev);
> -	pm_runtime_put_noidle(&client->dev);
>  
>  	if (client->irq > 0) {
>  		iio_triggered_buffer_cleanup(data->acc_indio_dev);



Thanks,
Mauro
Jonathan Cameron May 13, 2021, 4:46 p.m. UTC | #2
On Wed, 12 May 2021 15:45:11 +0200
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:

> Em Sun,  9 May 2021 12:33:35 +0100
> Jonathan Cameron <jic23@kernel.org> escreveu:
> 
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > No point in calling pm_runtime_put_noidle() that isn't balancing a get.
> > Note no actual impact because the runtime pm core protects against
> > a negative reference counter.
> > 
> > For the pm_runtime_resume_and_get() main interest is in clearing
> > out this old pattern to avoid it getting coppied into new submissions.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>  
> 
> LGTM.
> 
> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Applied. Thanks, J
> 
> > ---
> >  drivers/iio/imu/kmx61.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
> > index d3e06ce99c1e..1dabfd615dab 100644
> > --- a/drivers/iio/imu/kmx61.c
> > +++ b/drivers/iio/imu/kmx61.c
> > @@ -750,7 +750,7 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
> >  	}
> >  
> >  	if (on) {
> > -		ret = pm_runtime_get_sync(&data->client->dev);
> > +		ret = pm_runtime_resume_and_get(&data->client->dev);
> >  	} else {
> >  		pm_runtime_mark_last_busy(&data->client->dev);
> >  		ret = pm_runtime_put_autosuspend(&data->client->dev);
> > @@ -759,8 +759,6 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
> >  		dev_err(&data->client->dev,
> >  			"Failed: kmx61_set_power_state for %d, ret %d\n",
> >  			on, ret);
> > -		if (on)
> > -			pm_runtime_put_noidle(&data->client->dev);
> >  
> >  		return ret;
> >  	}
> > @@ -1426,7 +1424,6 @@ static int kmx61_remove(struct i2c_client *client)
> >  
> >  	pm_runtime_disable(&client->dev);
> >  	pm_runtime_set_suspended(&client->dev);
> > -	pm_runtime_put_noidle(&client->dev);
> >  
> >  	if (client->irq > 0) {
> >  		iio_triggered_buffer_cleanup(data->acc_indio_dev);  
> 
> 
> 
> Thanks,
> Mauro
diff mbox series

Patch

diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index d3e06ce99c1e..1dabfd615dab 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -750,7 +750,7 @@  static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
 	}
 
 	if (on) {
-		ret = pm_runtime_get_sync(&data->client->dev);
+		ret = pm_runtime_resume_and_get(&data->client->dev);
 	} else {
 		pm_runtime_mark_last_busy(&data->client->dev);
 		ret = pm_runtime_put_autosuspend(&data->client->dev);
@@ -759,8 +759,6 @@  static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device)
 		dev_err(&data->client->dev,
 			"Failed: kmx61_set_power_state for %d, ret %d\n",
 			on, ret);
-		if (on)
-			pm_runtime_put_noidle(&data->client->dev);
 
 		return ret;
 	}
@@ -1426,7 +1424,6 @@  static int kmx61_remove(struct i2c_client *client)
 
 	pm_runtime_disable(&client->dev);
 	pm_runtime_set_suspended(&client->dev);
-	pm_runtime_put_noidle(&client->dev);
 
 	if (client->irq > 0) {
 		iio_triggered_buffer_cleanup(data->acc_indio_dev);