aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/imu/inv_mpu6050
diff options
context:
space:
mode:
authorJean-Baptiste Maneyrol <jmaneyrol@invensense.com>2020-02-19 15:39:58 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-03-08 17:28:40 +0000
commit74a40e19f9db6606b5263aa08af2c684dd67b3d3 (patch)
tree5d145d254aa2f815e1b896ce4efeb96f5c657e16 /drivers/iio/imu/inv_mpu6050
parentiio: imu: inv_mpu6050: use runtime pm with autosuspend (diff)
downloadlinux-dev-74a40e19f9db6606b5263aa08af2c684dd67b3d3.tar.xz
linux-dev-74a40e19f9db6606b5263aa08af2c684dd67b3d3.zip
iio: imu: inv_mpu6050: temperature only work with accel/gyro
Temperature sensor works correctly only when accel and/or gyro is turned on. Prevent polling value if they are not running. Anyway it doesn't make sense to use it without sensor engines on. Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/imu/inv_mpu6050')
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 56e5731eb7de..7cb9ff3d3e94 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -598,6 +598,11 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
chan->channel2, val);
break;
case IIO_TEMP:
+ /* temperature sensor work only with accel and/or gyro */
+ if (!st->chip_config.accl_en && !st->chip_config.gyro_en) {
+ result = -EBUSY;
+ goto error_power_off;
+ }
if (!st->chip_config.temp_en) {
result = inv_mpu6050_switch_engine(st, true,
INV_MPU6050_SENSOR_TEMP);