[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zwj5jBm-_9_FX6ms@smile.fi.intel.com>
Date: Fri, 11 Oct 2024 13:10:20 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: vamoirid <vassilisamir@...il.com>
Cc: jic23@...nel.org, lars@...afoo.de, robh@...nel.org, krzk+dt@...nel.org,
conor+dt@...nel.org, anshulusr@...il.com, gustavograzs@...il.com,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 08/13] iio: chemical: bme680: add power management
On Thu, Oct 10, 2024 at 11:00:25PM +0200, vamoirid wrote:
> From: Vasileios Amoiridis <vassilisamir@...il.com>
>
> Add runtime power management to the device. To facilitate this, add also
> a struct dev * inside the bme680_data structure to have the device
> accesible from the data structure.
...
> --- a/drivers/iio/chemical/bme680.h
> +++ b/drivers/iio/chemical/bme680.h
> @@ -75,6 +75,7 @@
> #define BME680_CALIB_RANGE_3_LEN 5
>
> extern const struct regmap_config bme680_regmap_config;
> +extern const struct dev_pm_ops bmp280_dev_pm_ops;
Is pm.h being included already in this header? Otherwise you need to add it.
...
> struct regmap *regmap;
> struct bme680_calib bme680;
> struct mutex lock; /* Protect multiple serial R/W ops to device. */
> + struct device *dev;
Is it the same that you may get wia regmap_get_device()?
> u8 oversampling_temp;
> u8 oversampling_press;
> u8 oversampling_humid;
...
> + /* Enable runtime PM */
> + pm_runtime_get_noresume(dev);
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + pm_runtime_set_autosuspend_delay(dev, BME680_STARTUP_TIME_US * 100);
> + pm_runtime_use_autosuspend(dev);
> + pm_runtime_put(dev);
Can we use devm_pm_runtime_enable() for some of the above?
> + ret = devm_add_action_or_reset(dev, bme680_pm_disable, dev);
> + if (ret)
> + return ret;
...
> +static int bme680_runtime_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct bme680_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + ret = regulator_bulk_enable(BME680_NUM_SUPPLIES, data->supplies);
> + if (ret)
> + return ret;
> +
> + fsleep(BME680_STARTUP_TIME_US);
> +
> + ret = bme680_chip_config(data);
> + if (ret)
> + return ret;
> + ret = bme680_gas_config(data);
> + if (ret)
> + return ret;
> +
> + return 0;
return bme680_gas_config(...);
> +}
...
> +EXPORT_RUNTIME_DEV_PM_OPS(bme680_dev_pm_ops, bme680_runtime_suspend,
> + bme680_runtime_resume, NULL);
You also need pm.h for the macro IIRC.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists