OSDN Git Service

iio: iio-utils: use channel modifier scaling if it exists
authorMatt Ranostay <mranostay@gmail.com>
Mon, 22 Aug 2016 22:19:37 +0000 (15:19 -0700)
committerJonathan Cameron <jic23@kernel.org>
Mon, 29 Aug 2016 15:26:41 +0000 (16:26 +0100)
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 <mranostay@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
tools/iio/iio_utils.c

index 5eb6793..7a6d61c 100644 (file)
@@ -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,
@@ -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: