From 081df7f8582115c7b87f3516946acb829a1aa357 Mon Sep 17 00:00:00 2001 From: Sergey Larin Date: Sat, 26 Jan 2019 19:27:36 +0300 Subject: [PATCH] iio: gyro: mpu3050: get chip ID correctly According to the datasheet, the first bit of CHIP_ID register specifies the I2C bus state, and the last one does not belong to ID. Handle this correctly. Signed-off-by: Sergey Larin --- drivers/iio/gyro/mpu3050-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c index 77fac81a3adc..0c541cbf13a4 100644 --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -29,7 +29,7 @@ #include "mpu3050.h" -#define MPU3050_CHIP_ID 0x69 +#define MPU3050_CHIP_ID 0x68 /* * Register map: anything suffixed *_H is a big-endian high byte and always @@ -1176,8 +1176,8 @@ 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 & 0x7E) != MPU3050_CHIP_ID) { + dev_err(dev, "unsupported chip id %02x\n", (u8)(val & 0x7E)); ret = -ENODEV; goto err_power_down; } -- 2.20.1