Re: [PATCH v2 07/14] iio: accel: bma220: reset registers during init stage

Jonathan Cameron
2025-09-10T18:02:02Z

On Wed, 10 Sep 2025 10:57:12 +0300
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> Bring all configuration registers to default values during device probe().
>
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>

Hi Petre

One comment on code you happened to be moving. The patch itself looks good
to me so this is a 'whilst we are here' type comment, though should be addressed
in a separate patch.

thanks,

Jonathan

> +static int bma220_init(struct spi_device *spi)
> +{
> + int ret;
> + static const char * const regulator_names[] = { "vddd", "vddio", "vdda" };
> +
> + ret = devm_regulator_bulk_get_enable(&spi->dev,
> + ARRAY_SIZE(regulator_names),
> + regulator_names);
> + if (ret)
> + return dev_err_probe(&spi->dev, ret, "Failed to get regulators\n");
> +
> + ret = bma220_read_reg(spi, BMA220_REG_ID);
> + if (ret != BMA220_CHIP_ID)
> + return -ENODEV;

Not relevant to this patch as such, but we should relax this constraint so that
fallback compatibles work in device tree. Convention is to just print a
dev_info() message if we get a wrong ID and carry on.

> +
> + /* Make sure the chip is powered on and config registers are reset */
> + ret = bma220_power(spi, true);
> + if (ret)
> + return dev_err_probe(&spi->dev, ret, "Failed to power-on chip\n");
> +
> + ret = bma220_reset(spi, true);
> + if (ret)
> + return dev_err_probe(&spi->dev, ret, "Failed to soft reset chip\n");
> +
> + return 0;
> +}