[PATCH v4 2/3] iio: chemical: bme680: add regulators

Vasileios Amoiridis posted 3 patches 1 year, 2 months ago
There is a newer version of this series
[PATCH v4 2/3] iio: chemical: bme680: add regulators
Posted by Vasileios Amoiridis 1 year, 2 months ago
Add support for the regulators described in the dt-binding.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
---
 drivers/iio/chemical/bme680_core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
index 9783953e64e0..186e0a6cc2d7 100644
--- a/drivers/iio/chemical/bme680_core.c
+++ b/drivers/iio/chemical/bme680_core.c
@@ -15,6 +15,7 @@
 #include <linux/log2.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
@@ -111,6 +112,10 @@ enum bme680_scan {
 	BME680_GAS,
 };
 
+static const char *const bme680_supply_names[] = { "vdd", "vddio" };
+
+#define BME680_NUM_SUPPLIES ARRAY_SIZE(bme680_supply_names)
+
 struct bme680_data {
 	struct regmap *regmap;
 	struct bme680_calib bme680;
@@ -1114,6 +1119,14 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap,
 	data->heater_dur = 150;  /* milliseconds */
 	data->preheat_curr_mA = 0;
 
+	ret = devm_regulator_bulk_get_enable(dev, BME680_NUM_SUPPLIES,
+					     bme680_supply_names);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to get and enable supplies.\n");
+
+	fsleep(BME680_STARTUP_TIME_US);
+
 	ret = regmap_write(regmap, BME680_REG_SOFT_RESET, BME680_CMD_SOFTRESET);
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "Failed to reset chip\n");
-- 
2.43.0
Re: [PATCH v4 2/3] iio: chemical: bme680: add regulators
Posted by Jonathan Cameron 1 year, 2 months ago
On Thu, 28 Nov 2024 20:32:45 +0100
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:

> Add support for the regulators described in the dt-binding.
> 
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> ---
>  drivers/iio/chemical/bme680_core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
> index 9783953e64e0..186e0a6cc2d7 100644
> --- a/drivers/iio/chemical/bme680_core.c
> +++ b/drivers/iio/chemical/bme680_core.c
> @@ -15,6 +15,7 @@
>  #include <linux/log2.h>
>  #include <linux/module.h>
>  #include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/iio.h>
> @@ -111,6 +112,10 @@ enum bme680_scan {
>  	BME680_GAS,
>  };
>  
> +static const char *const bme680_supply_names[] = { "vdd", "vddio" };
> +
> +#define BME680_NUM_SUPPLIES ARRAY_SIZE(bme680_supply_names)
Trivial: What benefit do we get from this define that is used in one place?

> +
>  struct bme680_data {
>  	struct regmap *regmap;
>  	struct bme680_calib bme680;
> @@ -1114,6 +1119,14 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap,
>  	data->heater_dur = 150;  /* milliseconds */
>  	data->preheat_curr_mA = 0;
>  
> +	ret = devm_regulator_bulk_get_enable(dev, BME680_NUM_SUPPLIES,
	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(bme680_supply_names),
					     bme680_supply_names);

And don't worry about slightly over 80 chars line.

> +					     bme680_supply_names);
> +	if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "failed to get and enable supplies.\n");
> +
> +	fsleep(BME680_STARTUP_TIME_US);
> +
>  	ret = regmap_write(regmap, BME680_REG_SOFT_RESET, BME680_CMD_SOFTRESET);
>  	if (ret < 0)
>  		return dev_err_probe(dev, ret, "Failed to reset chip\n");
Re: [PATCH v4 2/3] iio: chemical: bme680: add regulators
Posted by Vasileios Amoiridis 1 year, 2 months ago
On Sat, Nov 30, 2024 at 02:26:48PM +0000, Jonathan Cameron wrote:
> On Thu, 28 Nov 2024 20:32:45 +0100
> Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> 
> > Add support for the regulators described in the dt-binding.
> > 
> > Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
> > ---
> >  drivers/iio/chemical/bme680_core.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
> > index 9783953e64e0..186e0a6cc2d7 100644
> > --- a/drivers/iio/chemical/bme680_core.c
> > +++ b/drivers/iio/chemical/bme680_core.c
> > @@ -15,6 +15,7 @@
> >  #include <linux/log2.h>
> >  #include <linux/module.h>
> >  #include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> >  
> >  #include <linux/iio/buffer.h>
> >  #include <linux/iio/iio.h>
> > @@ -111,6 +112,10 @@ enum bme680_scan {
> >  	BME680_GAS,
> >  };
> >  
> > +static const char *const bme680_supply_names[] = { "vdd", "vddio" };
> > +
> > +#define BME680_NUM_SUPPLIES ARRAY_SIZE(bme680_supply_names)
> Trivial: What benefit do we get from this define that is used in one place?
> 

Hi Jonathan,

Thanks for the review! This here made more sense in the beginning
because I was using it in more places but now it is indeed only used in
one place. I might as well drop it.

Cheers,
Vasilis

> > +
> >  struct bme680_data {
> >  	struct regmap *regmap;
> >  	struct bme680_calib bme680;
> > @@ -1114,6 +1119,14 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap,
> >  	data->heater_dur = 150;  /* milliseconds */
> >  	data->preheat_curr_mA = 0;
> >  
> > +	ret = devm_regulator_bulk_get_enable(dev, BME680_NUM_SUPPLIES,
> 	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(bme680_supply_names),
> 					     bme680_supply_names);
> 
> And don't worry about slightly over 80 chars line.
> 
> > +					     bme680_supply_names);
> > +	if (ret)
> > +		return dev_err_probe(dev, ret,
> > +				     "failed to get and enable supplies.\n");
> > +
> > +	fsleep(BME680_STARTUP_TIME_US);
> > +
> >  	ret = regmap_write(regmap, BME680_REG_SOFT_RESET, BME680_CMD_SOFTRESET);
> >  	if (ret < 0)
> >  		return dev_err_probe(dev, ret, "Failed to reset chip\n");
>
Re: [PATCH v4 2/3] iio: chemical: bme680: add regulators
Posted by Andy Shevchenko 1 year, 2 months ago
On Thu, Nov 28, 2024 at 08:32:45PM +0100, Vasileios Amoiridis wrote:
> Add support for the regulators described in the dt-binding.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


-- 
With Best Regards,
Andy Shevchenko