Skip to contentSkip to conversation

iio: lidar: return -EIO on invalid signal

PATCH Superseded Matt Ranostay 2 participants 4 messages Oct 25, 2015 – Nov 1, 2015 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: lidar: return -EIO on invalid signal

Returning zero from the measurment function has the side effect of corrupting the triggered buffer readings, better to use -EIO than a zero measurement reading.

---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2 -2
index 961f9f99..359beac 100644
@@ -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 -EIO since laser is likely pointed out of range */
 		if (ret & LIDAR_REG_STATUS_INVALID) {
 			*reg = 0;
-			ret = 0;
+			ret = -EIO;
 			break;
 		}
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 3 lines · Matt Ranostay

Returning zero from the measurment function has the side effect of corrupting the triggered buffer readings, better to use -EIO than a zero measurement reading.

When you say 'corrupting' what do you mean? As far as I can quickly see it will give a spurious 0 distance when it really means a long distance. Is that what you are referring to?

Jonathan

Quoted 24 lines
---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2 -2
index 961f9f99..359beac 100644
@@ -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 -EIO since laser is likely pointed out of range */
 		if (ret & LIDAR_REG_STATUS_INVALID) {
 			*reg = 0;
-			ret = 0;
+			ret = -EIO;
 			break;
 		}
 
#2 lore raw

Actually 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 and etc..

So there are spurious zero readings from the triggered buffer, and warning messages in the kernel log.

Thanks,

Matt

Quoted 34 lines · Jonathan Cameron
Quoted 3 lines · Matt Ranostay

Returning zero from the measurment function has the side effect of corrupting the triggered buffer readings, better to use -EIO than a zero measurement reading.

When you say 'corrupting' what do you mean? As far as I can quickly see it will give a spurious 0 distance when it really means a long distance. Is that what you are referring to?

Jonathan

Quoted 24 lines
---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2 -2
index 961f9f99..359beac 100644
@@ -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 -EIO since laser is likely pointed out of range */
              if (ret & LIDAR_REG_STATUS_INVALID) {
                      *reg = 0;
-                     ret = 0;
+                     ret = -EIO;
                      break;
              }
 
maintainer
#3 lore raw
Quoted 6 lines · Matt Ranostay

Actually 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 and etc..

So there are spurious zero readings from the triggered buffer, and warning messages in the kernel log.

Thanks for the clarification. I've added a version of this response to the patch description and applied to the fixes-togreg-post-rc1 branch I'm running at the moment as we have a few outstanding fixes for stuff going in during the merge window that is opening very soon.

Quoted 45 lines

Thanks,

Matt

Quoted 23 lines · Jonathan Cameron
Quoted 3 lines · Matt Ranostay

Returning zero from the measurment function has the side effect of corrupting the triggered buffer readings, better to use -EIO than a zero measurement reading.

When you say 'corrupting' what do you mean? As far as I can quickly see it will give a spurious 0 distance when it really means a long distance. Is that what you are referring to?

Jonathan

Quoted 14 lines
---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +0 -0
index 961f9f99..359beac 100644
@@ -130,10 +130,10 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
              if (ret < 0)
                      break;
 
Quoted 11 lines

drivers/iio/proximity/pulsedlight-lidar-lite-v2.c static int lidar_get_measurement(struct lidar_data *data, u16 *reg) · line 139

Quoted 10 lines
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +2 -2
-             /* return 0 since laser is likely pointed out of range */
+             /* return -EIO since laser is likely pointed out of range */
              if (ret & LIDAR_REG_STATUS_INVALID) {
                      *reg = 0;
-                     ret = 0;
+                     ret = -EIO;
                      break;
              }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html