Skip to contentSkip to conversation

iio: add driver for Bosch BMA400 accelerometer

PATCH Superseded Dan Robertson 3 participants 16 messages Dec 19, 2019 – Dec 20, 2019

Subsystems (3)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Dan Robertson

author maintainer
#0 lore raw

v7 cover iio: add driver for Bosch BMA400 accelerometer

I added basic support for the vdd and vddio regulators in this patchset version. I also added a MAINTAINERS entry for this driver as I do plan to submit some follow-up patchsets and I'd like to stay up to date on changes others make to this driver. If this is not the right time to add this or if there is a better way, please let me know.

Cheers,

- Dan

Changes in v7:

* Added MAINTAINERS entry
* Added basic vddio and vdd regulator support
* Added vddio and vdd supply to devicetree bindings
* Added interrupts to devicetree bindings

Changes in v6:

* Improve readability Kconfig options

Changes in v5:

* Move to using a function instead of lookup tables for scale and frequency conversions.
* Rename DT bindings to bosch,bma400.yaml
* Fixed other errors and improvements found by reviewers

Changes in v4:

* Fix error in DT bindings
* Fix typo when setting the OSR
* Simplified the cached sample frequency
* Fix the MODULE_LICENSE

Changes in v3:

* Use yaml format for DT bindings
* Remove strict dependency on OF
* Tidy Kconfig dependencies
* Stylistic changes
* Do not soft-reset device on remove

Changes in v2:

* Implemented iio_info -> read_avail
* Stylistic changes
* Implemented devicetree bindings

Dan Robertson (2):
dt-bindings: iio: accel: bma400: add bindings
iio: (bma400) add driver for the BMA400

Dan Robertson (3):
dt-bindings: iio: accel: bma400: add bindings
iio: (bma400) add driver for the BMA400
iio: (bma400) basic regulator support

 .../bindings/iio/accel/bosch,bma400.yaml      |  54 ++
 MAINTAINERS                                   |   7 +
 drivers/iio/accel/Kconfig                     |  17 +
 drivers/iio/accel/Makefile                    |   2 +
 drivers/iio/accel/bma400.h                    |  95 ++
 drivers/iio/accel/bma400_core.c               | 860 ++++++++++++++++++
 drivers/iio/accel/bma400_i2c.c                |  62 ++
 7 files changed, 1097 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml
 create mode 100644 drivers/iio/accel/bma400.h
 create mode 100644 drivers/iio/accel/bma400_core.c
 create mode 100644 drivers/iio/accel/bma400_i2c.c
author maintainer
#1 lore raw

PATCH v7 1/3 dt-bindings: iio: accel: bma400: add bindings

Add devicetree binding for the Bosch BMA400 3-axes ultra-low power accelerometer sensor.

---
 .../bindings/iio/accel/bosch,bma400.yaml      | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml
Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml new file +54 -0
new file mode 100644
index 000000000000..e87cb636b3e2
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/accel/bosch,bma400.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Bosch BMA400 triaxial acceleration sensor
+
+maintainers:
+  - Dan Robertson <[email protected]>
+
+description: |
+  Acceleration and temerature iio sensors with an i2c interface
+
+  Specifications about the sensor can be found at:
+    https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMA400-DS000.pdf
+
+properties:
+  compatible:
+    enum:
+      - bosch,bma400
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description: phandle to the regulator that provides power to the accelerometer
+
+  vddio-supply:
+    description: phandle to the regulator that provides power to the sensor's IO
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      accelerometer@14 {
+        compatible = "bosch,bma400";
+        reg = <0x14>;
+        vdd-supply = <&vdd>;
+        vddio-supply = <&vddio>;
+        interrupt-parent = <&gpio0>;
+        interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
+      };
+    };
author maintainer
#3 lore raw

PATCH v7 2/3 iio: (bma400) add driver for the BMA400

In reply to Dan Robertson

Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer. The driver supports reading from the acceleration and temperature registers. The driver also supports reading and configuring the output data rate, oversampling ratio, and scale.

---
 MAINTAINERS                     |   7 +
 drivers/iio/accel/Kconfig       |  16 +
 drivers/iio/accel/Makefile      |   2 +
 drivers/iio/accel/bma400.h      |  95 ++++
 drivers/iio/accel/bma400_core.c | 821 ++++++++++++++++++++++++++++++++
 drivers/iio/accel/bma400_i2c.c  |  62 +++
 6 files changed, 1003 insertions(+)
 create mode 100644 drivers/iio/accel/bma400.h
 create mode 100644 drivers/iio/accel/bma400_core.c
 create mode 100644 drivers/iio/accel/bma400_i2c.c
MAINTAINERS +7 -0
index ec020dc504ca..b7a48aad7f36 100644
@@ -3047,6 +3047,13 @@ S:	Supported
 F:	drivers/net/bonding/
 F:	include/uapi/linux/if_bonding.h
 
+BOSCH SENSORTEC BMA400 ACCELEROMETER IIO DRIVER
+M:	Dan Robertson <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/iio/accel/bma400*
+F:	Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml
+
 BPF (Safe dynamic programs and tools)
 M:	Alexei Starovoitov <[email protected]>
 M:	Daniel Borkmann <[email protected]>
drivers/iio/accel/Kconfig +16 -0
index d4ef35aeb579..670e60568033 100644
@@ -112,6 +112,22 @@ config BMA220
 	  To compile this driver as a module, choose M here: the
 	  module will be called bma220_spi.
 
+config BMA400
+	tristate "Bosch BMA400 3-Axis Accelerometer Driver"
+	select REGMAP
+	select BMA400_I2C if I2C
+	help
+	  Say Y here if you want to build a driver for the Bosch BMA400
+	  triaxial acceleration sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bma400_core and you will also get
+	  bma400_i2c if I2C is enabled.
+
+config BMA400_I2C
+	tristate
+	depends on BMA400
+
 config BMC150_ACCEL
 	tristate "Bosch BMC150 Accelerometer Driver"
 	select IIO_BUFFER
drivers/iio/accel/Makefile +2 -0
index 56bd0215e0d4..3a051cf37f40 100644
@@ -14,6 +14,8 @@ obj-$(CONFIG_ADXL372_I2C) += adxl372_i2c.o
 obj-$(CONFIG_ADXL372_SPI) += adxl372_spi.o
 obj-$(CONFIG_BMA180) += bma180.o
 obj-$(CONFIG_BMA220) += bma220_spi.o
+obj-$(CONFIG_BMA400) += bma400_core.o
+obj-$(CONFIG_BMA400_I2C) += bma400_i2c.o
 obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o
 obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o
 obj-$(CONFIG_BMC150_ACCEL_SPI) += bmc150-accel-spi.o
drivers/iio/accel/bma400.h new file +95 -0

95 lines not on this page · raw message

drivers/iio/accel/bma400_core.c new file +821 -0

821 lines not on this page · raw message

drivers/iio/accel/bma400_i2c.c new file +62 -0

62 lines not on this page · raw message

author maintainer
#4 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

MAINTAINERS S: Supported · line 3056

Quoted 9 lines · Dan Robertson

...

MAINTAINERS +7 -0
+BOSCH SENSORTEC BMA400 ACCELEROMETER IIO DRIVER
+M:	Dan Robertson <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/iio/accel/bma400*
+F:	Documentation/devicetree/bindings/iio/accel/bosch,bma400.yaml
+

I mixed up the Status tag. This should be S: Maintained. Will fix in v8.

Cheers,

- Dan

Reviewed-by on v7 2/3
#5 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

In reply to Dan Robertson
Quoted 6 lines · Dan Robertson

Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer. The driver supports reading from the acceleration and temperature registers. The driver also supports reading and configuring the output data rate, oversampling ratio, and scale.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

In reply to Dan Robertson
Quoted 4 lines · Dan Robertson

Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer. The driver supports reading from the acceleration and temperature registers. The driver also supports reading and configuring the output data rate, oversampling ratio, and scale.

...

drivers/iio/accel/bma400_core.c line 308

Quoted 13 lines
drivers/iio/accel/bma400_core.c new file +13 -0
+static int bma400_set_accel_output_data_rate(struct bma400_data *data,
+                                            int hz, int uhz)
+{
+       unsigned int idx;
+       unsigned int odr;
+       unsigned int val;
+       int ret;
+
+       if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
+               if (uhz || hz % BMA400_ACC_ODR_MIN_WHOLE_HZ)
+                       return -EINVAL;
+
+               val = hz / BMA400_ACC_ODR_MIN_WHOLE_HZ;

Again, AFAICS division may be avoided in both cases (% and / above) because of is_power_of_2() check below.
Can you revisit this?

Quoted 7 lines
drivers/iio/accel/bma400_core.c new file +7 -0
+               if (!is_power_of_2(val))
+                       return -EINVAL;
+
+               idx = __ffs(val) + BMA400_ACC_ODR_MIN_RAW + 1;
+       } else if (hz == BMA400_ACC_ODR_MIN_HZ && uhz == 500000) {
+               idx = BMA400_ACC_ODR_MIN_RAW;
+       } else {

drivers/iio/accel/bma400_core.c line 325

Quoted 10 lines
drivers/iio/accel/bma400_core.c new file +9 -0
+               return -EINVAL;
+       }
+
+       ret = regmap_read(data->regmap, BMA400_ACC_CONFIG1_REG, &val);
+       if (ret)
+               return ret;
+
+       /* preserve the range and normal mode osr */
 
+       odr = idx | (~BMA400_ACC_ODR_MASK & val);

Yoda style?

Quoted 9 lines
drivers/iio/accel/bma400_core.c new file +9 -0
+
+       ret = regmap_write(data->regmap, BMA400_ACC_CONFIG1_REG, odr);
+       if (ret)
+               return ret;
+
+       bma400_output_data_rate_from_raw(idx, &data->sample_freq.hz,
+                                        &data->sample_freq.uhz);
+       return 0;
+}

...

drivers/iio/accel/bma400_core.c line 443

Quoted 12 lines
drivers/iio/accel/bma400_core.c new file +12 -0
+int bma400_accel_scale_to_raw(struct bma400_data *data, unsigned int val)
+{
+       int scale = val / BMA400_SCALE_MIN;
+       int raw;
+
+       if (scale == 0)
+               return -EINVAL;
+
+       raw = __ffs(scale);
+
+       if (val % BMA400_SCALE_MIN || !is_power_of_2(scale))
+               return -EINVAL;

Ditto.

Quoted 3 lines
drivers/iio/accel/bma400_core.c new file +3 -0
+
+       return raw;
+}

...

Quoted 1 line

+out:

Make a little sense. Why not return directly?

Quoted 1 line

+ return ret;

...

drivers/iio/accel/bma400_core.c line 782

Quoted 2 lines
drivers/iio/accel/bma400_core.c new file +2 -0
+       ret = bma400_init(data);
+       if (ret < 0)

May it be positive value returned?

Quoted 1 line

+ return ret;

...

drivers/iio/accel/bma400_i2c.c line 22

Quoted 8 lines
drivers/iio/accel/bma400_i2c.c new file +7 -0
+static int bma400_i2c_probe(struct i2c_client *client,
+                           const struct i2c_device_id *id)
+{
+       struct regmap *regmap;
+
+       regmap = devm_regmap_init_i2c(client, &bma400_regmap_config);
 
+

Redundant blank line.

Quoted 7 lines
drivers/iio/accel/bma400_i2c.c new file +7 -0
+       if (IS_ERR(regmap)) {
+               dev_err(&client->dev, "failed to create regmap\n");
+               return PTR_ERR(regmap);
+       }
+
+       return bma400_probe(&client->dev, regmap, id->name);
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#7 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

Quoted 17 lines · Andy Shevchenko
Quoted 4 lines · Dan Robertson

Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer. The driver supports reading from the acceleration and temperature registers. The driver also supports reading and configuring the output data rate, oversampling ratio, and scale.

...

Quoted 9 lines
drivers/iio/accel/bma400_core.c new file +9 -0
+static int bma400_set_accel_output_data_rate(struct bma400_data *data,
+                                            int hz, int uhz)
+{
+       unsigned int idx;
+       unsigned int odr;
+       unsigned int val;
+       int ret;
+
+       if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
Quoted 8 lines

drivers/iio/accel/bma400_core.c line 308

Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (uhz || hz % BMA400_ACC_ODR_MIN_WHOLE_HZ)
+                       return -EINVAL;
+
+               val = hz / BMA400_ACC_ODR_MIN_WHOLE_HZ;

Again, AFAICS division may be avoided in both cases (% and / above) because of is_power_of_2() check below.
Can you revisit this?

Yeah I can update this in the next patchset, but I don't know if it is much more readable this way.

Quoted 16 lines
Quoted 15 lines
drivers/iio/accel/bma400_core.c new file +15 -0
+               if (!is_power_of_2(val))
+                       return -EINVAL;
+
+               idx = __ffs(val) + BMA400_ACC_ODR_MIN_RAW + 1;
+       } else if (hz == BMA400_ACC_ODR_MIN_HZ && uhz == 500000) {
+               idx = BMA400_ACC_ODR_MIN_RAW;
+       } else {
+               return -EINVAL;
+       }
+
+       ret = regmap_read(data->regmap, BMA400_ACC_CONFIG1_REG, &val);
+       if (ret)
+               return ret;
+
+       /* preserve the range and normal mode osr */
Quoted 3 lines
Quoted 1 line

+ odr = idx | (~BMA400_ACC_ODR_MASK & val);

Yoda style?

Fixed in v8.

Quoted 32 lines
Quoted 9 lines
drivers/iio/accel/bma400_core.c new file +9 -0
+
+       ret = regmap_write(data->regmap, BMA400_ACC_CONFIG1_REG, odr);
+       if (ret)
+               return ret;
+
+       bma400_output_data_rate_from_raw(idx, &data->sample_freq.hz,
+                                        &data->sample_freq.uhz);
+       return 0;
+}

...

drivers/iio/accel/bma400_core.c line 443

Quoted 12 lines
drivers/iio/accel/bma400_core.c new file +12 -0
+int bma400_accel_scale_to_raw(struct bma400_data *data, unsigned int val)
+{
+       int scale = val / BMA400_SCALE_MIN;
+       int raw;
+
+       if (scale == 0)
+               return -EINVAL;
+
+       raw = __ffs(scale);
+
+       if (val % BMA400_SCALE_MIN || !is_power_of_2(scale))
+               return -EINVAL;

Ditto.

Quoted 3 lines
drivers/iio/accel/bma400_core.c new file +3 -0
+
+       return raw;
+}

...

Quoted 3 lines
Quoted 1 line

+out:

Make a little sense. Why not return directly?

Mostly setup for the next patch in this patchset.

Quoted 8 lines
Quoted 1 line

+ return ret;

...

drivers/iio/accel/bma400_core.c line 782

Quoted 2 lines
drivers/iio/accel/bma400_core.c new file +2 -0
+       ret = bma400_init(data);
+       if (ret < 0)

May it be positive value returned?

Fixed in v8.

Cheers,

- Dan

#8 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

Quoted 21 lines · Dan Robertson
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Dan Robertson
drivers/iio/accel/bma400_core.c new file +9 -0
+static int bma400_set_accel_output_data_rate(struct bma400_data *data,
+                                            int hz, int uhz)
+{
+       unsigned int idx;
+       unsigned int odr;
+       unsigned int val;
+       int ret;
+
+       if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
Quoted 8 lines

drivers/iio/accel/bma400_core.c line 308

Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (uhz || hz % BMA400_ACC_ODR_MIN_WHOLE_HZ)
+                       return -EINVAL;
+
+               val = hz / BMA400_ACC_ODR_MIN_WHOLE_HZ;

Again, AFAICS division may be avoided in both cases (% and / above) because of is_power_of_2() check below.
Can you revisit this?

Quoted 2 lines

Yeah I can update this in the next patchset, but I don't know if it is much more readable this way.

You may describe the algo in the comment.

Let's see how it might look like

  if (uhz)
    return -EINVAL;
  idx = __ffs(val);
  /* We're expecting value to be 2^n * ODR_MIN_WHOLE_HZ */
  if ((val >> idx) != BMA400_ACC_ODR_MIN_WHOLE_HZ)
    retutn -EINVAL;
  idx += BMA400_ACC_ODR_MIN_RAW + 1;

Would it work?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (!is_power_of_2(val))
+                       return -EINVAL;
+
+               idx = __ffs(val) + BMA400_ACC_ODR_MIN_RAW + 1;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

Quoted 27 lines · Andy Shevchenko
Quoted 21 lines · Dan Robertson
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Dan Robertson
drivers/iio/accel/bma400_core.c new file +9 -0
+static int bma400_set_accel_output_data_rate(struct bma400_data *data,
+                                            int hz, int uhz)
+{
+       unsigned int idx;
+       unsigned int odr;
+       unsigned int val;
+       int ret;
+
+       if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
Quoted 8 lines

drivers/iio/accel/bma400_core.c line 308

Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (uhz || hz % BMA400_ACC_ODR_MIN_WHOLE_HZ)
+                       return -EINVAL;
+
+               val = hz / BMA400_ACC_ODR_MIN_WHOLE_HZ;

Again, AFAICS division may be avoided in both cases (% and / above) because of is_power_of_2() check below.
Can you revisit this?

Quoted 2 lines

Yeah I can update this in the next patchset, but I don't know if it is much more readable this way.

You may describe the algo in the comment.

Quoted 7 lines

Let's see how it might look like

  if (uhz)
    return -EINVAL;
  idx = __ffs(val);
  /* We're expecting value to be 2^n * ODR_MIN_WHOLE_HZ */
  if ((val >> idx) != BMA400_ACC_ODR_MIN_WHOLE_HZ)

Okay, this would require trickier conditional for the cases when MIN_WHOLE_HZ can be divided by 2^k...
Still from performance point of view it might be much faster than division.

Quoted 9 lines
    retutn -EINVAL;

idx += BMA400_ACC_ODR_MIN_RAW + 1;

Would it work?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (!is_power_of_2(val))
+                       return -EINVAL;
+
+               idx = __ffs(val) + BMA400_ACC_ODR_MIN_RAW + 1;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#10 lore raw

Re: [PATCH v7 2/3] iio: (bma400) add driver for the BMA400

Quoted 37 lines · Andy Shevchenko
Quoted 27 lines · Andy Shevchenko
Quoted 21 lines · Dan Robertson
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Dan Robertson
drivers/iio/accel/bma400_core.c new file +9 -0
+static int bma400_set_accel_output_data_rate(struct bma400_data *data,
+                                            int hz, int uhz)
+{
+       unsigned int idx;
+       unsigned int odr;
+       unsigned int val;
+       int ret;
+
+       if (hz >= BMA400_ACC_ODR_MIN_WHOLE_HZ) {
Quoted 8 lines

drivers/iio/accel/bma400_core.c line 308

Quoted 4 lines
drivers/iio/accel/bma400_core.c new file +4 -0
+               if (uhz || hz % BMA400_ACC_ODR_MIN_WHOLE_HZ)
+                       return -EINVAL;
+
+               val = hz / BMA400_ACC_ODR_MIN_WHOLE_HZ;

Again, AFAICS division may be avoided in both cases (% and / above) because of is_power_of_2() check below.
Can you revisit this?

Quoted 2 lines

Yeah I can update this in the next patchset, but I don't know if it is much more readable this way.

You may describe the algo in the comment.

Quoted 7 lines

Let's see how it might look like

  if (uhz)
    return -EINVAL;
  idx = __ffs(val);
  /* We're expecting value to be 2^n * ODR_MIN_WHOLE_HZ */
  if ((val >> idx) != BMA400_ACC_ODR_MIN_WHOLE_HZ)
Quoted 3 lines

Okay, this would require trickier conditional for the cases when MIN_WHOLE_HZ can be divided by 2^k...
Still from performance point of view it might be much faster than division.

I think the other checks will ensure we return -EINVAL in those cases. I ran a basic for loop and verified this.

Cheers,

- Dan

author maintainer
#11 lore raw

PATCH v7 3/3 iio: (bma400) basic regulator support

In reply to Dan Robertson

Add support for the VDD and VDDIO regulators using the regulator framework.

---
 drivers/iio/accel/Kconfig       |  1 +
 drivers/iio/accel/bma400_core.c | 49 +++++++++++++++++++++++++++++----
 2 files changed, 45 insertions(+), 5 deletions(-)
drivers/iio/accel/Kconfig +1 -0
index 670e60568033..9cfe9c790190 100644
@@ -116,6 +116,7 @@ config BMA400
 	tristate "Bosch BMA400 3-Axis Accelerometer Driver"
 	select REGMAP
 	select BMA400_I2C if I2C
+	select REGULATOR
 	help
 	  Say Y here if you want to build a driver for the Bosch BMA400
 	  triaxial acceleration sensor.
drivers/iio/accel/bma400_core.c +44 -5

100 lines not on this page · raw message

#13 lore raw

Re: [PATCH v7 3/3] iio: (bma400) basic regulator support

In reply to Dan Robertson
Quoted 3 lines · Dan Robertson

Add support for the VDD and VDDIO regulators using the regulator framework.

...

drivers/iio/accel/bma400_core.c static int bma400_init(struct bma400_data *data)

Quoted 3 lines
drivers/iio/accel/bma400_core.c +2 -0
+       data->vdd_supply = devm_regulator_get(data->dev, "vdd");
 
+       data->vddio_supply = devm_regulator_get(data->dev, "vddio");

devm_regulator_bulk_get() ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#14 lore raw

Re: [PATCH v7 3/3] iio: (bma400) basic regulator support

Quoted 11 lines · Andy Shevchenko
Quoted 3 lines · Dan Robertson

Add support for the VDD and VDDIO regulators using the regulator framework.

...

drivers/iio/accel/bma400_core.c static int bma400_init(struct bma400_data *data)

Quoted 3 lines
drivers/iio/accel/bma400_core.c +2 -0
+       data->vdd_supply = devm_regulator_get(data->dev, "vdd");
 
+       data->vddio_supply = devm_regulator_get(data->dev, "vddio");

devm_regulator_bulk_get() ?

I always thought to use regulator_bulk* maybe 3 regulators and definitely for more that 4 as it also clouds the view bit and is not as straightforward to read as the single functions, but I suppose it is a bit subjective :)

Linus Walleij

author maintainer
#15 lore raw

Re: [PATCH v7 3/3] iio: (bma400) basic regulator support

Quoted 10 lines · Linus Walleij
Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Dan Robertson

Add support for the VDD and VDDIO regulators using the regulator framework.

...

Quoted 1 line

+ data->vdd_supply = devm_regulator_get(data->dev, "vdd");

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

+ data->vddio_supply = devm_regulator_get(data->dev, "vddio");

devm_regulator_bulk_get() ?

I always thought to use regulator_bulk* maybe 3 regulators and definitely for more that 4 as it also clouds the view bit and is not as straightforward to read as the single functions, but I suppose it is a bit subjective :)

I tend to agree, but I think in this case it will at least simplify the goto's.

Cheers,

- Dan