Commit 409a51e0 authored by Sergey Larin's avatar Sergey Larin Committed by Jonathan Cameron

iio: gyro: mpu3050: fix chip ID reading

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

Note that there are chips out there that have a value such that
the id check currently fails.
Signed-off-by: default avatarSergey Larin <cerg2010cerg2010@mail.ru>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 20ea39ef
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include "mpu3050.h" #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 * Register map: anything suffixed *_H is a big-endian high byte and always
...@@ -1176,8 +1177,9 @@ int mpu3050_common_probe(struct device *dev, ...@@ -1176,8 +1177,9 @@ int mpu3050_common_probe(struct device *dev,
goto err_power_down; goto err_power_down;
} }
if (val != MPU3050_CHIP_ID) { if ((val & MPU3050_CHIP_ID_MASK) != MPU3050_CHIP_ID) {
dev_err(dev, "unsupported chip id %02x\n", (u8)val); dev_err(dev, "unsupported chip id %02x\n",
(u8)(val & MPU3050_CHIP_ID_MASK));
ret = -ENODEV; ret = -ENODEV;
goto err_power_down; goto err_power_down;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment