iio: tools: make generic_buffer look for "-trigger"
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 24 Mar 2016 08:39:14 +0000 (09:39 +0100)
committerJonathan Cameron <jic23@kernel.org>
Sun, 3 Apr 2016 09:27:49 +0000 (10:27 +0100)
All the ST Sensors use the old "<foo>-trigger" rather than the
standard "<foo>-devN" new standard suffix for triggers. Now much
to do about it since it is ABI, but make the testing tools
recognize it too.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
tools/iio/generic_buffer.c

index 01c4f67801e0e0d6ce865f7a4f241e7425645860..c42b7f836b484c1063a2aa6c3c6058c8a5a3dfbc 100644 (file)
@@ -304,7 +304,19 @@ int main(int argc, char **argv)
                        }
                }
 
-               /* Verify the trigger exists */
+               /* Look for this "-devN" trigger */
+               trig_num = find_type_by_name(trigger_name, "trigger");
+               if (trig_num < 0) {
+                       /* OK try the simpler "-trigger" suffix instead */
+                       free(trigger_name);
+                       ret = asprintf(&trigger_name,
+                                      "%s-trigger", device_name);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               goto error_free_dev_dir_name;
+                       }
+               }
+
                trig_num = find_type_by_name(trigger_name, "trigger");
                if (trig_num < 0) {
                        fprintf(stderr, "Failed to find the trigger %s\n",