Skip to content

Commit 57572ca

Browse files
committed
iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
The regulator enables were after the check on the chip variant, which was very unlikely to return a correct value when not powered. Presumably all the device anyone is testing on have a regulator that is already powered up when this code runs for reasons beyond the scope of this driver. Move the read call down a few lines. Fixes: 3cf7ded ("iio: accel: bma400: basic regulator support") Signed-off-by: Jonathan Cameron <[email protected]> Reviewed-by: Dan Robertson <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 207777d commit 57572ca

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/iio/accel/bma400_core.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -869,18 +869,6 @@ static int bma400_init(struct bma400_data *data)
869869
unsigned int val;
870870
int ret;
871871

872-
/* Try to read chip_id register. It must return 0x90. */
873-
ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val);
874-
if (ret) {
875-
dev_err(data->dev, "Failed to read chip id register\n");
876-
return ret;
877-
}
878-
879-
if (val != BMA400_ID_REG_VAL) {
880-
dev_err(data->dev, "Chip ID mismatch\n");
881-
return -ENODEV;
882-
}
883-
884872
data->regulators[BMA400_VDD_REGULATOR].supply = "vdd";
885873
data->regulators[BMA400_VDDIO_REGULATOR].supply = "vddio";
886874
ret = devm_regulator_bulk_get(data->dev,
@@ -906,6 +894,18 @@ static int bma400_init(struct bma400_data *data)
906894
if (ret)
907895
return ret;
908896

897+
/* Try to read chip_id register. It must return 0x90. */
898+
ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val);
899+
if (ret) {
900+
dev_err(data->dev, "Failed to read chip id register\n");
901+
return ret;
902+
}
903+
904+
if (val != BMA400_ID_REG_VAL) {
905+
dev_err(data->dev, "Chip ID mismatch\n");
906+
return -ENODEV;
907+
}
908+
909909
ret = bma400_get_power_mode(data);
910910
if (ret) {
911911
dev_err(data->dev, "Failed to get the initial power-mode\n");

0 commit comments

Comments
 (0)