Skip to contentSkip to conversation

iio: iio-utils: use channel modifier scaling if it exists

PATCH Superseded Matt Ranostay 2 participants 3 messages Jul 31, 2016 – Aug 21, 2016 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: iio-utils: use channel modifier scaling if it exists

Now there are channel modifiers with their own scaling those should be used when possible over the generic channel type scaling.

Cc Marek Vasut <[email protected]>
Cc Jonathan Cameron <[email protected]>
---
 tools/iio/iio_utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
tools/iio/iio_utils.c +7 -4
index 5eb6793f3972..7a6d61c6c012 100644
@@ -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:
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Matt Ranostay

Now there are channel modifiers with their own scaling those should be used when possible over the generic channel type scaling.

Cc Marek Vasut <[email protected]>
Cc Jonathan Cameron <[email protected]>

Jonathan,

Know you are probably still digging out your inbox since your holiday. Any comments on this one?

Thanks,

Matt

Quoted 36 lines
---
 tools/iio/iio_utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
tools/iio/iio_utils.c +7 -5
index 5eb6793f3972..7a6d61c6c012 100644
@@ -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:
--

2.7.4

maintainer
#2 lore raw
Quoted 4 lines · Matt Ranostay
Quoted 3 lines · Matt Ranostay

Now there are channel modifiers with their own scaling those should be used when possible over the generic channel type scaling.

Quoted 9 lines
Quoted 3 lines
Cc Marek Vasut <[email protected]>
Cc Jonathan Cameron <[email protected]>

Jonathan,

Know you are probably still digging out your inbox since your holiday. Any comments on this one?

Indeed - still not caught up. Was hoping for space on the plane, but of course despite it being the middle of the day the person in front of me immediately put their chair fully back. Laptop too big to fit at that point!

Jonathan

Quoted 40 lines

Thanks,

Matt

Quoted 36 lines
---
 tools/iio/iio_utils.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
tools/iio/iio_utils.c +7 -5
index 5eb6793f3972..7a6d61c6c012 100644
@@ -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:
--

2.7.4