Skip to content

Commit

Permalink
iio: lsiio: fix error code handling error
Browse files Browse the repository at this point in the history
commit acf50b3
"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 <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
Acked-by: Hartmut Knaack <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
linusw authored and jic23 committed Aug 12, 2015
1 parent 06d2f6c commit af255cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/iio/lsiio.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int dump_one_device(const char *dev_dir_name)
return -EINVAL;

ret = read_sysfs_string("name", dev_dir_name, name);
if (ret)
if (ret < 0)
return ret;

printf("Device %03d: %s\n", dev_idx, name);
Expand All @@ -92,7 +92,7 @@ static int dump_one_trigger(const char *dev_dir_name)
return -EINVAL;

ret = read_sysfs_string("name", dev_dir_name, name);
if (ret)
if (ret < 0)
return ret;

printf("Trigger %03d: %s\n", dev_idx, name);
Expand Down

0 comments on commit af255cd

Please sign in to comment.