Re: [PATCH v5 3/3] iio: chemical: bme680: add power management

From: Andy Shevchenko
Date: Mon Dec 02 2024 - 15:45:27 EST


On Mon, Dec 02, 2024 at 08:23:41PM +0100, Vasileios Amoiridis wrote:
> Add runtime power management to the device.

...

> + ret = pm_runtime_resume_and_get(dev);
> + if (ret)
> + return ret;
> +
> + ret = __bme680_read_raw(indio_dev, chan, val, val2, mask);
> + pm_runtime_mark_last_busy(dev);
> + pm_runtime_put_autosuspend(dev);

Side note: as long as idle method is not defined (NULL) the above dance is
already taken into account in the regular put.

...

> +static int bme680_buffer_preenable(struct iio_dev *indio_dev)
> +{
> + struct bme680_data *data = iio_priv(indio_dev);
> + struct device *dev = regmap_get_device(data->regmap);
> + int ret;

> + ret = pm_runtime_resume_and_get(dev);
> + if (ret)
> + return ret;
> +
> + return 0;

Either this is broken (if the above can return positive codes), or can be
replaced with direct return:

return pm_...

(but I believe it's the former and you wanted something like if (ret < 0)
there).

> +}

--
With Best Regards,
Andy Shevchenko