summaryrefslogtreecommitdiffstats
path: root/tools/iio
diff options
context:
space:
mode:
authorEva Rachel Retuya <eraretuya@gmail.com>2016-10-14 18:18:39 +0800
committerJonathan Cameron <jic23@kernel.org>2016-10-23 19:33:53 +0100
commit4e2cf0e21f5c4792a0b21325557974ddbf111d2f (patch)
tree5384f4b983952ae1cc0a03d17724795d3a0a84d1 /tools/iio
parentb440f1d90ec54fd2586537ea46e958343ad4b151 (diff)
downloadlinux-4e2cf0e21f5c4792a0b21325557974ddbf111d2f.tar.gz
linux-4e2cf0e21f5c4792a0b21325557974ddbf111d2f.tar.bz2
linux-4e2cf0e21f5c4792a0b21325557974ddbf111d2f.zip
tools: iio: iio_generic_buffer: add -A to force-enable all channels
If attribute/s is/are already enabled (by default or via scripts or manual interaction), issuing -a will fail to enable the channels thereby one has to manually disable the said attribute/s before proceeding with auto-enabling. Add a command-line option -A to force-activate all channels regardless of their current state. Suggested-by: Alison Schofield <amsfield22@gmail.com> Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r--tools/iio/iio_generic_buffer.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 85e23291d3b9..31ddd3abe04f 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -247,6 +247,7 @@ void print_usage(void)
fprintf(stderr, "Usage: generic_buffer [options]...\n"
"Capture, convert and output data from IIO device buffer\n"
" -a Auto-activate all available channels\n"
+ " -A Force-activate ALL channels\n"
" -c <n> Do n conversions\n"
" -e Disable wait for event (new data)\n"
" -g Use trigger-less mode\n"
@@ -347,16 +348,22 @@ int main(int argc, char **argv)
int noevents = 0;
int notrigger = 0;
char *dummy;
+ int force = 0;
struct iio_channel_info *channels = NULL;
register_cleanup();
- while ((c = getopt_long(argc, argv, "ac:egl:n:N:t:T:w:?", longopts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "aAc:egl:n:N:t:T:w:?", longopts,
+ NULL)) != -1) {
switch (c) {
case 'a':
autochannels = AUTOCHANNELS_ENABLED;
break;
+ case 'A':
+ autochannels = AUTOCHANNELS_ENABLED;
+ force = 1;
+ break;
case 'c':
errno = 0;
num_loops = strtoul(optarg, &dummy, 10);
@@ -519,15 +526,15 @@ int main(int argc, char **argv)
"diag %s\n", dev_dir_name);
goto error;
}
- if (num_channels && autochannels == AUTOCHANNELS_ENABLED) {
+ if ((num_channels && autochannels == AUTOCHANNELS_ENABLED) && !force) {
fprintf(stderr, "Auto-channels selected but some channels "
"are already activated in sysfs\n");
fprintf(stderr, "Proceeding without activating any channels\n");
}
- if (!num_channels && autochannels == AUTOCHANNELS_ENABLED) {
- fprintf(stderr,
- "No channels are enabled, enabling all channels\n");
+ if ((!num_channels && autochannels == AUTOCHANNELS_ENABLED) ||
+ ((autochannels == AUTOCHANNELS_ENABLED) && force)) {
+ fprintf(stderr, "Enabling all channels\n");
ret = enable_disable_all_channels(dev_dir_name, 1);
if (ret) {