Re: [PATCH v4 3/3] iio: chemical: bme680: add power management
From: Andy Shevchenko
Date: Fri Nov 29 2024 - 09:33:14 EST
On Thu, Nov 28, 2024 at 08:32:46PM +0100, Vasileios Amoiridis wrote:
> Add runtime power management to the device.
...
> + struct bme680_data *data = iio_priv(indio_dev);
> + struct device *dev = regmap_get_device(data->regmap);
> + int ret;
> +
> + pm_runtime_get_sync(dev);
> + ret = __bme680_read_raw(indio_dev, chan, val, val2, mask);
Does it make sense to read something if previous call failed?
Most likely you wanted to use
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);
> +
> + return ret;
...
> +static int bme680_write_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int val, int val2, long mask)
Ditto.
...
> +{
> + struct bme680_data *data = iio_priv(indio_dev);
> + struct device *dev = regmap_get_device(data->regmap);
> +
> + pm_runtime_get_sync(dev);
No error check?
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko