[PATCH v4 09/19] iio: accel: bma220: turn power supplies on

Petre Rodan
2025-10-05T13:13:10Z

Add devm_regulator_bulk_get_enable() to device probe().

Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
---
v1->v2 split from larger patch
v2->v3 change commit desc (Jonathan)
v4 dev ptr (Andy)
---
drivers/iio/accel/bma220_core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
index 00fe1064486aa469f7ad15593027c7ec86197365..319a3d6867ee5ac2da64c9baf02a760865302ee8 100644
--- a/drivers/iio/accel/bma220_core.c
+++ b/drivers/iio/accel/bma220_core.c
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm.h>
+#include <linux/regulator/consumer.h>
#include <linux/types.h>
#include <linux/spi/spi.h>

@@ -230,6 +231,12 @@ static int bma220_init(struct spi_device *spi)
{
int ret;
struct device *dev = &spi->dev;
+ static const char * const regulator_names[] = { "vddd", "vddio", "vdda" };
+
+ ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
+ regulator_names);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to get regulators\n");

ret = bma220_read_reg(spi, BMA220_REG_ID);
if (ret < 0)

--
2.49.1