Re: [PATCH 27/28] iio: pressure: icp10100: Use pm_runtime_resume_and_get() + handle errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Em Sun,  9 May 2021 12:33:53 +0100
Jonathan Cameron <jic23@xxxxxxxxxx> escreveu:

> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> 
> Using this new call makes it easy to handle failures in resume as it
> doesn't hold a reference count if it exits with an error.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Cc: Jean-Baptiste Maneyrol <jmaneyrol@xxxxxxxxxxxxxx>
> ---
>  drivers/iio/pressure/icp10100.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c
> index 48759fc4bf18..80cd66688731 100644
> --- a/drivers/iio/pressure/icp10100.c
> +++ b/drivers/iio/pressure/icp10100.c
> @@ -250,7 +250,9 @@ static int icp10100_get_measures(struct icp10100_state *st,
>  	__be16 measures[3];
>  	int ret;
>  
> -	pm_runtime_get_sync(&st->client->dev);
> +	ret = pm_runtime_resume_and_get(&st->client->dev);
> +	if (ret < 0)
> +		return ret;
>  
>  	mutex_lock(&st->lock);
>  	cmd = &icp10100_cmd_measure[st->mode];


This one has a logic similar to a patch I commented earlier in this
series. At probing time, it does:

        pm_runtime_get_noresume(&client->dev);
        pm_runtime_set_active(&client->dev);
        pm_runtime_enable(&client->dev);
        pm_runtime_set_autosuspend_delay(&client->dev, 2000);
        pm_runtime_use_autosuspend(&client->dev);
        pm_runtime_put(&client->dev);
        ret = devm_add_action_or_reset(&client->dev, icp10100_pm_disable,
                                       &client->dev);


Here, get/put are balanced, but the icp10100_pm_disable logic is:

static void icp10100_pm_disable(void *data)
{
        struct device *dev = data;

        pm_runtime_put_sync_suspend(dev);
        pm_runtime_disable(dev);
}

Not sure what RPM get() it is trying to balance there.

Thanks,
Mauro



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux