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

Joshua Crofts
2026-05-05T22:34:36Z

On Tue, 5 May 2026 at 19:49, Sanjay Chitroda <sanjayembeddedse@gmail.com> wrote:
>
> From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
> 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@huawei.com>
> Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
> ---
> 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).

--
Kind regards

CJD