提交 45a6b821 编写于 作者: M Matt Ranostay 提交者: Jonathan Cameron

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: NMatt Ranostay <mranostay@gmail.com>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 2e9fed42
...@@ -130,10 +130,10 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) ...@@ -130,10 +130,10 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
if (ret < 0) if (ret < 0)
break; 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) { if (ret & LIDAR_REG_STATUS_INVALID) {
*reg = 0; *reg = 0;
ret = 0; ret = -EINVAL;
break; break;
} }
...@@ -197,7 +197,7 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) ...@@ -197,7 +197,7 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
if (!ret) { if (!ret) {
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
iio_get_time_ns()); iio_get_time_ns());
} else { } else if (ret != -EINVAL) {
dev_err(&data->client->dev, "cannot read LIDAR measurement"); dev_err(&data->client->dev, "cannot read LIDAR measurement");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册