All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iio: tools: generic_buffer: auto-enable channels
@ 2016-04-12  8:55 Linus Walleij
  2016-04-12  9:14 ` Peter Meerwald-Stadler
  2016-04-16 12:45 ` Jonathan Cameron
  0 siblings, 2 replies; 5+ messages in thread
From: Linus Walleij @ 2016-04-12  8:55 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: Linus Walleij

If no channels are enabled when we run generic_buffer on a
device, add a command-line option to just enable all of them,
run the sampling and disable them all again afterwards.

This is extremely useful when I'm low-level testing my
sensors with interrupts and triggers, sample session:

root@Ux500:/ lsiio
Device 000: lsm303dlh_accel
Device 001: lis331dl_accel
Device 002: l3g4200d
Device 003: lsm303dlh_magn
Device 004: lps001wp
Trigger 000: lsm303dlh_accel-trigger
Trigger 001: lis331dl_accel-trigger
Trigger 002: l3g4200d-trigger

root@Ux500:/ generic_buffer -a -c 10 -n l3g4200d
iio device number being used is 2
iio trigger number being used is 2
No channels are enabled, enabling all channels
Enabling: in_anglvel_x_en
Enabling: in_anglvel_y_en
Enabling: in_anglvel_z_en
Enabling: in_timestamp_en
/sys/bus/iio/devices/iio:device2 l3g4200d-trigger
-3.593664 -0.713133 4.870143 946684863662292480
3.225546 0.867357 -4.945878 946684863671875000
-0.676413 0.127296 0.106641 946684863681488037
-0.661113 0.110160 0.128826 946684863690673828
-0.664173 0.113067 0.123471 946684863700683593
-0.664938 0.109395 0.124848 946684863710144042
-0.664173 0.110619 0.130203 946684863719512939
-0.666162 0.111231 0.132651 946684863729125976
-0.668610 0.111690 0.130662 946684863738739013
-0.660501 0.110466 0.131733 946684863748565673
Disabling: in_anglvel_x_en
Disabling: in_anglvel_y_en
Disabling: in_anglvel_z_en
Disabling: in_timestamp_en

Pure awesomeness. If some channels have been enabled through
scripts or manual interaction, nothing happens.

Acked-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Provide for using the -a flag to indicate that you want all
  available channels enabled.
---
 tools/iio/generic_buffer.c | 90 +++++++++++++++++++++++++++++++++++++++++-----
 tools/iio/iio_utils.h      |  7 ++++
 2 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index c42b7f836b48..81ebead47547 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -191,10 +191,51 @@ void process_scan(char *data,
 	printf("\n");
 }
 
+int enable_disable_all_channels(char *dev_dir_name, int enable)
+{
+	const struct dirent *ent;
+	char scanelemdir[256];
+	DIR *dp;
+	int ret;
+
+	snprintf(scanelemdir, sizeof(scanelemdir),
+		 FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name);
+	scanelemdir[sizeof(scanelemdir)-1] = '\0';
+
+	dp = opendir(scanelemdir);
+	if (!dp) {
+		fprintf(stderr, "Enabling/disabling channels: can't open %s\n",
+			scanelemdir);
+		return -EIO;
+	}
+
+	ret = -ENOENT;
+	while (ent = readdir(dp), ent) {
+		if (check_suffix(ent->d_name, "_en")) {
+			printf("%sabling: %s\n",
+			       enable ? "En" : "Dis",
+			       ent->d_name);
+			ret = write_sysfs_int(ent->d_name, scanelemdir,
+					      enable);
+			if (ret < 0)
+				fprintf(stderr, "Failed to enable/disable %s\n",
+					ent->d_name);
+		}
+	}
+
+	if (closedir(dp) == -1) {
+		perror("Enabling/disabling channels: "
+		       "Failed to close directory");
+		return -errno;
+	}
+	return 0;
+}
+
 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"
 		"  -c <n>     Do n conversions\n"
 		"  -e         Disable wait for event (new data)\n"
 		"  -g         Use trigger-less mode\n"
@@ -225,12 +266,16 @@ int main(int argc, char **argv)
 	int scan_size;
 	int noevents = 0;
 	int notrigger = 0;
+	int autochannels = 0;
 	char *dummy;
 
 	struct iio_channel_info *channels;
 
-	while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
+	while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) {
 		switch (c) {
+		case 'a':
+			autochannels = 1;
+			break;
 		case 'c':
 			errno = 0;
 			num_loops = strtoul(optarg, &dummy, 10);
@@ -340,14 +385,36 @@ int main(int argc, char **argv)
 			"diag %s\n", dev_dir_name);
 		goto error_free_triggername;
 	}
-	if (!num_channels) {
+	if (num_channels && autochannels) {
+		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) {
 		fprintf(stderr,
-			"No channels are enabled, we have nothing to scan.\n");
-		fprintf(stderr, "Enable channels manually in "
-			FORMAT_SCAN_ELEMENTS_DIR
-			"/*_en and try again.\n", dev_dir_name);
-		ret = -ENOENT;
-		goto error_free_triggername;
+			"No channels are enabled, enabling all channels\n");
+
+		ret = enable_disable_all_channels(dev_dir_name, 1);
+		if (ret) {
+			fprintf(stderr, "Failed to enable all channels\n");
+			goto error_free_triggername;
+		}
+
+		/* This flags that we need to disable the channels again */
+		autochannels = 2;
+		ret = build_channel_array(dev_dir_name, &channels,
+					  &num_channels);
+		if (ret) {
+			fprintf(stderr, "Problem reading scan element "
+				"information\n"
+				"diag %s\n", dev_dir_name);
+			goto error_disable_channels;
+		}
+		if (!num_channels) {
+			fprintf(stderr, "Still no channels after "
+				"auto-enabling, giving up\n");
+			goto error_disable_channels;
+		}
 	}
 
 	/*
@@ -479,7 +546,12 @@ error_free_channels:
 error_free_triggername:
 	if (datardytrigger)
 		free(trigger_name);
-
+error_disable_channels:
+	if (autochannels == 2) {
+		ret = enable_disable_all_channels(dev_dir_name, 0);
+		if (ret)
+			fprintf(stderr, "Failed to disable all channels\n");
+	}
 error_free_dev_dir_name:
 	free(dev_dir_name);
 
diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
index e3503bfe538b..9d5601421820 100644
--- a/tools/iio/iio_utils.h
+++ b/tools/iio/iio_utils.h
@@ -52,6 +52,13 @@ struct iio_channel_info {
 	unsigned location;
 };
 
+static inline int check_suffix(const char *str, const char *suffix)
+{
+	return strlen(str) > strlen(suffix) &&
+		strncmp(str+strlen(str)-strlen(suffix),
+			suffix, strlen(suffix)) == 0;
+}
+
 int iioutils_break_up_name(const char *full_name, char **generic_name);
 int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
 		      unsigned *shift, uint64_t *mask, unsigned *be,
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: tools: generic_buffer: auto-enable channels
  2016-04-12  8:55 [PATCH v2] iio: tools: generic_buffer: auto-enable channels Linus Walleij
@ 2016-04-12  9:14 ` Peter Meerwald-Stadler
  2016-04-14  7:32   ` Linus Walleij
  2016-04-16 12:45 ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Meerwald-Stadler @ 2016-04-12  9:14 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jonathan Cameron, linux-iio


> This is extremely useful when I'm low-level testing my
> sensors with interrupts and triggers, sample session:

 
> Pure awesomeness. If some channels have been enabled through
> scripts or manual interaction, nothing happens.

I like!

> Acked-by: Daniel Baluta <daniel.baluta@intel.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Provide for using the -a flag to indicate that you want all
>   available channels enabled.
> ---
>  tools/iio/generic_buffer.c | 90 +++++++++++++++++++++++++++++++++++++++++-----
>  tools/iio/iio_utils.h      |  7 ++++
>  2 files changed, 88 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
> index c42b7f836b48..81ebead47547 100644
> --- a/tools/iio/generic_buffer.c
> +++ b/tools/iio/generic_buffer.c
> @@ -191,10 +191,51 @@ void process_scan(char *data,
>  	printf("\n");
>  }
>  
> +int enable_disable_all_channels(char *dev_dir_name, int enable)

could be static?
well, nothing in generic_buffer.c is...

> +{
> +	const struct dirent *ent;
> +	char scanelemdir[256];
> +	DIR *dp;
> +	int ret;
> +
> +	snprintf(scanelemdir, sizeof(scanelemdir),
> +		 FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name);
> +	scanelemdir[sizeof(scanelemdir)-1] = '\0';
> +
> +	dp = opendir(scanelemdir);
> +	if (!dp) {

maybe perror() can be used here, it's used for closedir() check

> +		fprintf(stderr, "Enabling/disabling channels: can't open %s\n",
> +			scanelemdir);
> +		return -EIO;
> +	}
> +
> +	ret = -ENOENT;
> +	while (ent = readdir(dp), ent) {
> +		if (check_suffix(ent->d_name, "_en")) {
> +			printf("%sabling: %s\n",
> +			       enable ? "En" : "Dis",
> +			       ent->d_name);
> +			ret = write_sysfs_int(ent->d_name, scanelemdir,
> +					      enable);
> +			if (ret < 0)
> +				fprintf(stderr, "Failed to enable/disable %s\n",
> +					ent->d_name);
> +		}
> +	}
> +
> +	if (closedir(dp) == -1) {
> +		perror("Enabling/disabling channels: "
> +		       "Failed to close directory");
> +		return -errno;
> +	}
> +	return 0;
> +}
> +
>  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"
>  		"  -c <n>     Do n conversions\n"
>  		"  -e         Disable wait for event (new data)\n"
>  		"  -g         Use trigger-less mode\n"
> @@ -225,12 +266,16 @@ int main(int argc, char **argv)
>  	int scan_size;
>  	int noevents = 0;
>  	int notrigger = 0;
> +	int autochannels = 0;

maybe an enum for autochannels? it can be 0/1/2

>  	char *dummy;
>  
>  	struct iio_channel_info *channels;
>  
> -	while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
> +	while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) {
>  		switch (c) {
> +		case 'a':
> +			autochannels = 1;
> +			break;
>  		case 'c':
>  			errno = 0;
>  			num_loops = strtoul(optarg, &dummy, 10);
> @@ -340,14 +385,36 @@ int main(int argc, char **argv)
>  			"diag %s\n", dev_dir_name);
>  		goto error_free_triggername;
>  	}
> -	if (!num_channels) {
> +	if (num_channels && autochannels) {
> +		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) {
>  		fprintf(stderr,
> -			"No channels are enabled, we have nothing to scan.\n");
> -		fprintf(stderr, "Enable channels manually in "
> -			FORMAT_SCAN_ELEMENTS_DIR
> -			"/*_en and try again.\n", dev_dir_name);
> -		ret = -ENOENT;
> -		goto error_free_triggername;
> +			"No channels are enabled, enabling all channels\n");
> +
> +		ret = enable_disable_all_channels(dev_dir_name, 1);
> +		if (ret) {
> +			fprintf(stderr, "Failed to enable all channels\n");
> +			goto error_free_triggername;
> +		}
> +
> +		/* This flags that we need to disable the channels again */
> +		autochannels = 2;
> +		ret = build_channel_array(dev_dir_name, &channels,
> +					  &num_channels);
> +		if (ret) {
> +			fprintf(stderr, "Problem reading scan element "
> +				"information\n"
> +				"diag %s\n", dev_dir_name);
> +			goto error_disable_channels;
> +		}
> +		if (!num_channels) {
> +			fprintf(stderr, "Still no channels after "
> +				"auto-enabling, giving up\n");
> +			goto error_disable_channels;
> +		}
>  	}
>  
>  	/*
> @@ -479,7 +546,12 @@ error_free_channels:
>  error_free_triggername:
>  	if (datardytrigger)
>  		free(trigger_name);
> -
> +error_disable_channels:
> +	if (autochannels == 2) {
> +		ret = enable_disable_all_channels(dev_dir_name, 0);
> +		if (ret)
> +			fprintf(stderr, "Failed to disable all channels\n");
> +	}
>  error_free_dev_dir_name:
>  	free(dev_dir_name);
>  
> diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
> index e3503bfe538b..9d5601421820 100644
> --- a/tools/iio/iio_utils.h
> +++ b/tools/iio/iio_utils.h
> @@ -52,6 +52,13 @@ struct iio_channel_info {
>  	unsigned location;
>  };
>  
> +static inline int check_suffix(const char *str, const char *suffix)

prefix with iioutils_ maybe?

> +{
> +	return strlen(str) > strlen(suffix) &&

it should be >= probably such that
check_suffix("abc", "abc") is 1, currently returns 0

the other corner-case is
check_suffix("abc", "") which is 1, OK


> +		strncmp(str+strlen(str)-strlen(suffix),
> +			suffix, strlen(suffix)) == 0;
> +}
> +
>  int iioutils_break_up_name(const char *full_name, char **generic_name);
>  int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
>  		      unsigned *shift, uint64_t *mask, unsigned *be,
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: tools: generic_buffer: auto-enable channels
  2016-04-12  9:14 ` Peter Meerwald-Stadler
@ 2016-04-14  7:32   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2016-04-14  7:32 UTC (permalink / raw)
  To: Peter Meerwald-Stadler; +Cc: Jonathan Cameron, linux-iio@vger.kernel.org

On Tue, Apr 12, 2016 at 11:14 AM, Peter Meerwald-Stadler
<pmeerw@pmeerw.net> wrote:

>> +int enable_disable_all_channels(char *dev_dir_name, int enable)
>
> could be static?
> well, nothing in generic_buffer.c is...

OK I will make it static, and then submit a separate patch to staticize the rest
of generic_buffer.c local functions.

>> +     dp = opendir(scanelemdir);
>> +     if (!dp) {
>
> maybe perror() can be used here, it's used for closedir() check

perror() does not support arguments.
perror("foo"); is OK.
perror("%s: foo", __func__); does not work.

So we have to use printf(stderr, ....);

>> +     int autochannels = 0;
>
> maybe an enum for autochannels? it can be 0/1/2

OK. It breaks a bit with the style of the file, but I will
submit a version like so.

>> +static inline int check_suffix(const char *str, const char *suffix)
>
> prefix with iioutils_ maybe?

OK

>> +     return strlen(str) > strlen(suffix) &&
>
> it should be >= probably such that
> check_suffix("abc", "abc") is 1, currently returns 0

OK fixed it, nice catch!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: tools: generic_buffer: auto-enable channels
  2016-04-12  8:55 [PATCH v2] iio: tools: generic_buffer: auto-enable channels Linus Walleij
  2016-04-12  9:14 ` Peter Meerwald-Stadler
@ 2016-04-16 12:45 ` Jonathan Cameron
  2016-04-16 14:05   ` Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2016-04-16 12:45 UTC (permalink / raw)
  To: Linus Walleij, linux-iio

On 12/04/16 09:55, Linus Walleij wrote:
> If no channels are enabled when we run generic_buffer on a
> device, add a command-line option to just enable all of them,
> run the sampling and disable them all again afterwards.
> 
> This is extremely useful when I'm low-level testing my
> sensors with interrupts and triggers, sample session:
> 
> root@Ux500:/ lsiio
> Device 000: lsm303dlh_accel
> Device 001: lis331dl_accel
> Device 002: l3g4200d
> Device 003: lsm303dlh_magn
> Device 004: lps001wp
> Trigger 000: lsm303dlh_accel-trigger
> Trigger 001: lis331dl_accel-trigger
> Trigger 002: l3g4200d-trigger
> 
> root@Ux500:/ generic_buffer -a -c 10 -n l3g4200d
> iio device number being used is 2
> iio trigger number being used is 2
> No channels are enabled, enabling all channels
> Enabling: in_anglvel_x_en
> Enabling: in_anglvel_y_en
> Enabling: in_anglvel_z_en
> Enabling: in_timestamp_en
> /sys/bus/iio/devices/iio:device2 l3g4200d-trigger
> -3.593664 -0.713133 4.870143 946684863662292480
> 3.225546 0.867357 -4.945878 946684863671875000
> -0.676413 0.127296 0.106641 946684863681488037
> -0.661113 0.110160 0.128826 946684863690673828
> -0.664173 0.113067 0.123471 946684863700683593
> -0.664938 0.109395 0.124848 946684863710144042
> -0.664173 0.110619 0.130203 946684863719512939
> -0.666162 0.111231 0.132651 946684863729125976
> -0.668610 0.111690 0.130662 946684863738739013
> -0.660501 0.110466 0.131733 946684863748565673
> Disabling: in_anglvel_x_en
> Disabling: in_anglvel_y_en
> Disabling: in_anglvel_z_en
> Disabling: in_timestamp_en
> 
> Pure awesomeness. If some channels have been enabled through
> scripts or manual interaction, nothing happens.
> 
> Acked-by: Daniel Baluta <daniel.baluta@intel.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Provide for using the -a flag to indicate that you want all
>   available channels enabled.
Good plan.  I'll wait for the updated version but am fine with this
in principle.
> ---
>  tools/iio/generic_buffer.c | 90 +++++++++++++++++++++++++++++++++++++++++-----
>  tools/iio/iio_utils.h      |  7 ++++
>  2 files changed, 88 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
> index c42b7f836b48..81ebead47547 100644
> --- a/tools/iio/generic_buffer.c
> +++ b/tools/iio/generic_buffer.c
> @@ -191,10 +191,51 @@ void process_scan(char *data,
>  	printf("\n");
>  }
>  
> +int enable_disable_all_channels(char *dev_dir_name, int enable)
> +{
> +	const struct dirent *ent;
> +	char scanelemdir[256];
> +	DIR *dp;
> +	int ret;
> +
> +	snprintf(scanelemdir, sizeof(scanelemdir),
> +		 FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name);
> +	scanelemdir[sizeof(scanelemdir)-1] = '\0';
> +
> +	dp = opendir(scanelemdir);
> +	if (!dp) {
> +		fprintf(stderr, "Enabling/disabling channels: can't open %s\n",
> +			scanelemdir);
> +		return -EIO;
> +	}
> +
> +	ret = -ENOENT;
> +	while (ent = readdir(dp), ent) {
> +		if (check_suffix(ent->d_name, "_en")) {
> +			printf("%sabling: %s\n",
> +			       enable ? "En" : "Dis",
> +			       ent->d_name);
> +			ret = write_sysfs_int(ent->d_name, scanelemdir,
> +					      enable);
> +			if (ret < 0)
> +				fprintf(stderr, "Failed to enable/disable %s\n",
> +					ent->d_name);
> +		}
> +	}
> +
> +	if (closedir(dp) == -1) {
> +		perror("Enabling/disabling channels: "
> +		       "Failed to close directory");
> +		return -errno;
> +	}
> +	return 0;
> +}
> +
>  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"
>  		"  -c <n>     Do n conversions\n"
>  		"  -e         Disable wait for event (new data)\n"
>  		"  -g         Use trigger-less mode\n"
> @@ -225,12 +266,16 @@ int main(int argc, char **argv)
>  	int scan_size;
>  	int noevents = 0;
>  	int notrigger = 0;
> +	int autochannels = 0;
>  	char *dummy;
>  
>  	struct iio_channel_info *channels;
>  
> -	while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
> +	while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) {
>  		switch (c) {
> +		case 'a':
> +			autochannels = 1;
> +			break;
>  		case 'c':
>  			errno = 0;
>  			num_loops = strtoul(optarg, &dummy, 10);
> @@ -340,14 +385,36 @@ int main(int argc, char **argv)
>  			"diag %s\n", dev_dir_name);
>  		goto error_free_triggername;
>  	}
> -	if (!num_channels) {
> +	if (num_channels && autochannels) {
> +		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) {
>  		fprintf(stderr,
> -			"No channels are enabled, we have nothing to scan.\n");
> -		fprintf(stderr, "Enable channels manually in "
> -			FORMAT_SCAN_ELEMENTS_DIR
> -			"/*_en and try again.\n", dev_dir_name);
> -		ret = -ENOENT;
> -		goto error_free_triggername;
> +			"No channels are enabled, enabling all channels\n");
> +
> +		ret = enable_disable_all_channels(dev_dir_name, 1);
> +		if (ret) {
> +			fprintf(stderr, "Failed to enable all channels\n");
> +			goto error_free_triggername;
> +		}
> +
> +		/* This flags that we need to disable the channels again */
> +		autochannels = 2;
> +		ret = build_channel_array(dev_dir_name, &channels,
> +					  &num_channels);
> +		if (ret) {
> +			fprintf(stderr, "Problem reading scan element "
> +				"information\n"
> +				"diag %s\n", dev_dir_name);
> +			goto error_disable_channels;
> +		}
> +		if (!num_channels) {
> +			fprintf(stderr, "Still no channels after "
> +				"auto-enabling, giving up\n");
> +			goto error_disable_channels;
> +		}
>  	}
>  
>  	/*
> @@ -479,7 +546,12 @@ error_free_channels:
>  error_free_triggername:
>  	if (datardytrigger)
>  		free(trigger_name);
> -
> +error_disable_channels:
> +	if (autochannels == 2) {
> +		ret = enable_disable_all_channels(dev_dir_name, 0);
> +		if (ret)
> +			fprintf(stderr, "Failed to disable all channels\n");
> +	}
>  error_free_dev_dir_name:
>  	free(dev_dir_name);
>  
> diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
> index e3503bfe538b..9d5601421820 100644
> --- a/tools/iio/iio_utils.h
> +++ b/tools/iio/iio_utils.h
> @@ -52,6 +52,13 @@ struct iio_channel_info {
>  	unsigned location;
>  };
>  
> +static inline int check_suffix(const char *str, const char *suffix)
> +{
> +	return strlen(str) > strlen(suffix) &&
> +		strncmp(str+strlen(str)-strlen(suffix),
> +			suffix, strlen(suffix)) == 0;
> +}
> +
>  int iioutils_break_up_name(const char *full_name, char **generic_name);
>  int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
>  		      unsigned *shift, uint64_t *mask, unsigned *be,
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] iio: tools: generic_buffer: auto-enable channels
  2016-04-16 12:45 ` Jonathan Cameron
@ 2016-04-16 14:05   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2016-04-16 14:05 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio@vger.kernel.org

On Sat, Apr 16, 2016 at 2:45 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> On 12/04/16 09:55, Linus Walleij wrote:

>> ChangeLog v1->v2:
>> - Provide for using the -a flag to indicate that you want all
>>   available channels enabled.
>
> Good plan.  I'll wait for the updated version but am fine with this
> in principle.

I think I sent out v3 already, you have mail ;)

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-16 14:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-12  8:55 [PATCH v2] iio: tools: generic_buffer: auto-enable channels Linus Walleij
2016-04-12  9:14 ` Peter Meerwald-Stadler
2016-04-14  7:32   ` Linus Walleij
2016-04-16 12:45 ` Jonathan Cameron
2016-04-16 14:05   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.