iio: imu: inv_mpu6050: Use as standalone trigger
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 22 Mar 2021 13:24:08 +0000 (14:24 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 29 Mar 2021 10:18:45 +0000 (11:18 +0100)
commit454c219f5d8452eff87b701735ae1224f4410356
tree698575f10c71504d15a7cc88459ac6715aa7ae81
parent4e102429f3dc62dce546f6107e34a4284634196d
iio: imu: inv_mpu6050: Use as standalone trigger

It may happen that the MPU6050 is the only hardware
trigger available on your system such as this:

> lsiio
Device 003: hscdtd008a
Device 001: mpu6050
Device 002: gp2ap002
Device 000: ab8500-gpadc
Trigger 000: mpu6050-dev1

And when you want to use it to read periodically from
your magnetometer like this:

> iio_generic_buffer -a -c 100 -n hscdtd008a -t mpu6050-dev1

Then the following happens:

[  209.951334] Internal error: Oops: 5 [#1] SMP ARM
(...)
[  209.981969] Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
[  209.988925] PC is at inv_scan_query_mpu6050+0x8/0xb8
[  209.993914] LR is at inv_mpu6050_set_enable+0x40/0x194

This is because since we are not using any channels from the
same device, the indio_dev->active_scan_mask is NULL.

Just checking for that and bailing out is however not enough:
we have to enable some kind of FIFO for the readout to work.
So enable the temperature as a dummy FIFO and all works
fine.

Not suitable for backporting to stable.  It is an odd corner case
and does not represent a regression.

Fixes: 09a642b78523 ("Invensense MPU6050 Device Driver.")
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210322132408.1003443-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c