Commit af255cd5 authored by Linus Walleij's avatar Linus Walleij Committed by Jonathan Cameron

iio: lsiio: fix error code handling error

commit acf50b35
"tools:iio:lsiio: add error handling"
introduced error handling of errors returned from
read_sysfs_string(), but with a simple if (retval),
missing the fact that these functions return a positive
value if the read was successful.

As a result lsiio regresses and does not show any
devices on my filesystem. Fix this by checking for
only negative error codes.

Cc: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarHartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 06d2f6ca
...@@ -69,7 +69,7 @@ static int dump_one_device(const char *dev_dir_name) ...@@ -69,7 +69,7 @@ static int dump_one_device(const char *dev_dir_name)
return -EINVAL; return -EINVAL;
ret = read_sysfs_string("name", dev_dir_name, name); ret = read_sysfs_string("name", dev_dir_name, name);
if (ret) if (ret < 0)
return ret; return ret;
printf("Device %03d: %s\n", dev_idx, name); printf("Device %03d: %s\n", dev_idx, name);
...@@ -92,7 +92,7 @@ static int dump_one_trigger(const char *dev_dir_name) ...@@ -92,7 +92,7 @@ static int dump_one_trigger(const char *dev_dir_name)
return -EINVAL; return -EINVAL;
ret = read_sysfs_string("name", dev_dir_name, name); ret = read_sysfs_string("name", dev_dir_name, name);
if (ret) if (ret < 0)
return ret; return ret;
printf("Trigger %03d: %s\n", dev_idx, name); printf("Trigger %03d: %s\n", dev_idx, name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment