diff options
author | Sergey Larin <cerg2010cerg2010@mail.ru> | 2019-03-02 19:54:55 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-04-27 09:36:34 +0200 |
commit | 8bd3fd46ec23375740e7f29bafce4a11f6cff1d2 (patch) | |
tree | bf6e891d3f69cf303b9dcb3697ff0f4c80c324fb | |
parent | 6f3e66b155f02dd90a30c9307f4900256eafa3f1 (diff) | |
download | linux-stable-8bd3fd46ec23375740e7f29bafce4a11f6cff1d2.tar.gz linux-stable-8bd3fd46ec23375740e7f29bafce4a11f6cff1d2.tar.bz2 linux-stable-8bd3fd46ec23375740e7f29bafce4a11f6cff1d2.zip |
iio: gyro: mpu3050: fix chip ID reading
commit 409a51e0a4a5f908763191fae2c29008632eb712 upstream.
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: Sergey Larin <cerg2010cerg2010@mail.ru>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/iio/gyro/mpu3050-core.c | 8 |
1 files 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; } |