[PATCH] iio: iio_utils: accept channels with no offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The function build_channel_array() will currently bail out
if the IIO device does not have a *_offset sysfs file. However
this offset is not compulsory, see
Documentation/ABI/testing/sysfs-bus-iio, and the ST sensors
does not provide an offset so the functions fail with these
sensors.

Fix this by alloing the offset check to return -ENOENT and if
it does, assume the offset is zero as per the ABI.

Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
---
 tools/iio/iio_utils.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index ec9ab7f9ae4c..9ea4b7c79558 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -479,7 +479,10 @@ int build_channel_array(const char *device_dir,
 						       device_dir,
 						       current->name,
 						       current->generic_name);
-			if (ret < 0)
+			if (ret == -ENOENT) {
+				/* Assume zero offset if not present */
+				current->offset = 0.0;
+			} else if (ret < 0)
 				goto error_cleanup_array;
 			ret = iioutils_get_type(&current->is_signed,
 						&current->bytes,
-- 
2.4.3

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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux