iio: lidar: return -EINVAL on invalid signal
v2 cover iio: lidar: return -EINVAL on invalid signal
Changes from v1:
* Changed EIO to EINVAL
* Don't display error message on invalid signal since will fill up the kernel log messages.
Matt Ranostay (1):
iio: lidar: return -EINVAL on invalid signal
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/1 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.
Signed-off-by Matt Ranostay <[email protected]>
--- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +3 -3
@@ -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" ); }
Signature · 1 line
1.9.1