diff options
author | Matt Ranostay <mranostay@gmail.com> | 2015-10-26 20:18:23 -0700 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-11-21 15:56:53 +0000 |
commit | 45a6b8218df54087c3bb8dc731424d8789d31790 (patch) | |
tree | 4807f065fc392f11cf68667c75244a398b2547c2 /drivers/iio/proximity | |
parent | 2e9fed42209b17116c6221e136ccbd3f252f5f86 (diff) | |
download | linux-45a6b8218df54087c3bb8dc731424d8789d31790.tar.gz linux-45a6b8218df54087c3bb8dc731424d8789d31790.tar.bz2 linux-45a6b8218df54087c3bb8dc731424d8789d31790.zip |
iio: lidar: return -EINVAL on invalid signal
Returning zero from the measurment function has the side effect of
corrupting the triggered buffer readings, better to use -EINVAL than
a zero measurement reading.
The INVALID status happens even it isn't out of range
sometimes roughly once every second or two. This can be from an
invalid second signal return path. Hence there are spurious zero
readings from the triggered buffer, and warning messages in the kernel
log.
Signed-off-by: Matt Ranostay <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/proximity')
-rw-r--r-- | drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 961f9f990faf..e544fcfd5ced 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -130,10 +130,10 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) if (ret < 0) break; - /* return 0 since laser is likely pointed out of range */ + /* return -EINVAL since laser is likely pointed out of range */ if (ret & LIDAR_REG_STATUS_INVALID) { *reg = 0; - ret = 0; + ret = -EINVAL; break; } @@ -197,7 +197,7 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) if (!ret) { iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, iio_get_time_ns()); - } else { + } else if (ret != -EINVAL) { dev_err(&data->client->dev, "cannot read LIDAR measurement"); } |