All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: gyro: mpu3050: fix chip ID reading
@ 2019-03-02 16:54 Sergey Larin
  2019-03-02 18:08 ` Jonathan Cameron
  2019-03-03  9:12 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Sergey Larin @ 2019-03-02 16:54 UTC (permalink / raw)
  To: linus.walleij, jic23, knaack.h, lars, pmeerw; +Cc: linux-iio, Sergey Larin

According to the datasheet, the last bit of CHIP_ID register controls
I2C bus, and the first one is unused. Handle this correctly.

Signed-off-by: Sergey Larin <cerg2010cerg2010@mail.ru>
---
 drivers/iio/gyro/mpu3050-core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index 77fac81a3adc..5ddebede31a6 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -29,7 +29,8 @@
 
 #include "mpu3050.h"
 
-#define MPU3050_CHIP_ID		0x69
+#define MPU3050_CHIP_ID		0x68
+#define MPU3050_CHIP_ID_MASK	0x7E
 
 /*
  * Register map: anything suffixed *_H is a big-endian high byte and always
@@ -1176,8 +1177,9 @@ int mpu3050_common_probe(struct device *dev,
 		goto err_power_down;
 	}
 
-	if (val != MPU3050_CHIP_ID) {
-		dev_err(dev, "unsupported chip id %02x\n", (u8)val);
+	if ((val & MPU3050_CHIP_ID_MASK) != MPU3050_CHIP_ID) {
+		dev_err(dev, "unsupported chip id %02x\n",
+				(u8)(val & MPU3050_CHIP_ID_MASK));
 		ret = -ENODEV;
 		goto err_power_down;
 	}
-- 
2.21.0


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

end of thread, other threads:[~2019-03-03 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-02 16:54 [PATCH] iio: gyro: mpu3050: fix chip ID reading Sergey Larin
2019-03-02 18:08 ` Jonathan Cameron
2019-03-02 18:48   ` Sergey Larin
2019-03-03 11:58     ` Jonathan Cameron
2019-03-03  9:12 ` Linus Walleij

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.