Re: [PATCH v3 06/10] iio: accel: mma8452: convert to bulk regulator usage

From: Jonathan Cameron

Date: Mon May 18 2026 - 09:37:47 EST


On Wed, 6 May 2026 00:34:22 +0200
Joshua Crofts <joshua.crofts1@xxxxxxxxx> wrote:

> On Tue, 5 May 2026 at 19:49, Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx> wrote:
> >
> > From: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
> >
> > The "vdd" and "vddio" regulators are always controlled together. Switch
> > to the regulator bulk API to handle setup, enable, and disable paths in
> > a single call.
> >
> > No functional change intended.
> >
> > Suggested-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> > Signed-off-by: Sanjay Chitroda <sanjayembeddedse@xxxxxxxxx>
> > ---
> > drivers/iio/accel/mma8452.c | 59 ++++++++++---------------------------
> > 1 file changed, 15 insertions(+), 44 deletions(-)
> >
> > diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> > index b49949792190..1c984c708ec3 100644
> > --- a/drivers/iio/accel/mma8452.c
> > +++ b/drivers/iio/accel/mma8452.c
> > @@ -111,8 +111,7 @@ struct mma8452_data {
> > u8 data_cfg;
> > const struct mma_chip_info *chip_info;
> > int sleep_val;
> > - struct regulator *vdd_reg;
> > - struct regulator *vddio_reg;
> > + struct regulator_bulk_data regs[2];
> >
> > /* Ensure correct alignment of time stamp when present */
> > struct {
> > @@ -1570,25 +1569,15 @@ static int mma8452_probe(struct i2c_client *client)
> > if (ret)
> > return ret;
> >
> > - data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
> > - if (IS_ERR(data->vdd_reg))
> > - return dev_err_probe(&client->dev, PTR_ERR(data->vdd_reg),
> > - "failed to get VDD regulator!\n");
> > -
> > - data->vddio_reg = devm_regulator_get(&client->dev, "vddio");
> > - if (IS_ERR(data->vddio_reg))
> > - return dev_err_probe(&client->dev, PTR_ERR(data->vddio_reg),
> > - "failed to get VDDIO regulator!\n");
> > -
> > - ret = regulator_enable(data->vdd_reg);
> > + data->regs[0].supply = "vdd";
> > + data->regs[1].supply = "vddio";
> > + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regs), data->regs);
>
> Since you're using ARRAY_SIZE(), it would be good to add a <linux/array_size.h>
> include, as it's currently pulling the macro from elsewhere. Perhaps
> run the IWYU
> tool to check (any header additions/removals stemming from IWYU would go in a
> separate patch however).
Fully agree that there are missing includes in the file.
ARRAY_SIZE() is already in use so ideally an IWYU header additions patch
should precede this one that adds another user.

Given Andy's comments as well need addressing I'll stop here in picking up the series.
Jonathan

>