All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
@ 2022-10-02 14:41 Jonathan Cameron
  2022-10-28 13:07 ` Dan Robertson
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2022-10-02 14:41 UTC (permalink / raw)
  To: linux-iio; +Cc: Jonathan Cameron, Dan Robertson

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

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: 3cf7ded15e40 ("iio: accel: bma400: basic regulator support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Dan Robertson <dan@dlrobertson.com>
---
 drivers/iio/accel/bma400_core.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index e8de88e6cfb9..81bfec9e20cc 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -869,18 +869,6 @@ static int bma400_init(struct bma400_data *data)
 	unsigned int val;
 	int ret;
 
-	/* Try to read chip_id register. It must return 0x90. */
-	ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val);
-	if (ret) {
-		dev_err(data->dev, "Failed to read chip id register\n");
-		return ret;
-	}
-
-	if (val != BMA400_ID_REG_VAL) {
-		dev_err(data->dev, "Chip ID mismatch\n");
-		return -ENODEV;
-	}
-
 	data->regulators[BMA400_VDD_REGULATOR].supply = "vdd";
 	data->regulators[BMA400_VDDIO_REGULATOR].supply = "vddio";
 	ret = devm_regulator_bulk_get(data->dev,
@@ -902,6 +890,18 @@ static int bma400_init(struct bma400_data *data)
 	if (ret)
 		return ret;
 
+	/* Try to read chip_id register. It must return 0x90. */
+	ret = regmap_read(data->regmap, BMA400_CHIP_ID_REG, &val);
+	if (ret) {
+		dev_err(data->dev, "Failed to read chip id register\n");
+		return ret;
+	}
+
+	if (val != BMA400_ID_REG_VAL) {
+		dev_err(data->dev, "Chip ID mismatch\n");
+		return -ENODEV;
+	}
+
 	ret = bma400_get_power_mode(data);
 	if (ret) {
 		dev_err(data->dev, "Failed to get the initial power-mode\n");
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
  2022-10-02 14:41 [PATCH] iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID Jonathan Cameron
@ 2022-10-28 13:07 ` Dan Robertson
  2022-10-29 11:25   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Robertson @ 2022-10-28 13:07 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

On Sun, Oct 02, 2022 at 03:41:33PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> 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: 3cf7ded15e40 ("iio: accel: bma400: basic regulator support")
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Reviewed-by: Dan Robertson <dan@dlrobertson.com>

Thanks for catching this!

Cheers,

 - Dan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
  2022-10-28 13:07 ` Dan Robertson
@ 2022-10-29 11:25   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2022-10-29 11:25 UTC (permalink / raw)
  To: Dan Robertson; +Cc: linux-iio, Jonathan Cameron

On Fri, 28 Oct 2022 13:07:47 +0000
Dan Robertson <dan@dlrobertson.com> wrote:

> On Sun, Oct 02, 2022 at 03:41:33PM +0100, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > 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: 3cf7ded15e40 ("iio: accel: bma400: basic regulator support")
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>  
> 
> Reviewed-by: Dan Robertson <dan@dlrobertson.com>
> 
> Thanks for catching this!

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

> 
> Cheers,
> 
>  - Dan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-29 11:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 14:41 [PATCH] iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID Jonathan Cameron
2022-10-28 13:07 ` Dan Robertson
2022-10-29 11:25   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.