Skip to content

Commit

Permalink
iio: iio-utils: use channel modifier scaling if it exists
Browse files Browse the repository at this point in the history
Now there are channel modifiers with their own scaling those should be
used when possible over the generic channel type scaling.

Examples are of IIO_TEMP channel having a generic scaling value, and
another having IIO_MOD_TEMP_AMBIENT modifier with another scaling value.

Previously the first scaling value for a channel type would be applied
to all channels of like type in iio_generic_buffer

Signed-off-by: Matt Ranostay <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
mranostay authored and jic23 committed Aug 29, 2016
1 parent 9d47964 commit 6356f1b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/iio/iio_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,

ret = -ENOENT;
while (ent = readdir(dp), ent)
/*
* Do we allow devices to override a generic name with
* a specific one?
*/
if ((strcmp(builtname, ent->d_name) == 0) ||
(strcmp(builtname_generic, ent->d_name) == 0)) {
ret = asprintf(&filename,
Expand Down Expand Up @@ -178,6 +174,13 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
sysfsfp = 0;
free(filename);
filename = 0;

/*
* Avoid having a more generic entry overwriting
* the settings.
*/
if (strcmp(builtname, ent->d_name) == 0)
break;
}

error_close_sysfsfp:
Expand Down

0 comments on commit 6356f1b

Please sign in to comment.