From: Doru Gucea <doru.gucea@intel.com>
To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Doru Gucea <doru.gucea@intel.com>
Subject: [PATCH] iio: generic_buffer: add watermark logic
Date: Tue, 26 Apr 2016 18:15:45 +0300 [thread overview]
Message-ID: <1461683745-1006-1-git-send-email-doru.gucea@intel.com> (raw)
Some IIO devices with FIFO buffers accept setting the watermark
value from /sys/bus/iio/devices/iio:deviceX/buffer/watermark.
This patch adds the '-m' command line parameter for easily setting
the watermark.
Signed-off-by: Doru Gucea <doru.gucea@intel.com>
---
tools/iio/generic_buffer.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index 01c4f67..f806b52 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -199,6 +199,7 @@ void print_usage(void)
" -e Disable wait for event (new data)\n"
" -g Use trigger-less mode\n"
" -l <n> Set buffer length to n samples\n"
+ " -m <n> Set watermark to n samples\n"
" -n <name> Set device name (mandatory)\n"
" -t <name> Set trigger name\n"
" -w <n> Set delay between reads in us (event-less mode)\n");
@@ -225,11 +226,12 @@ int main(int argc, char **argv)
int scan_size;
int noevents = 0;
int notrigger = 0;
+ int watermark = 0;
char *dummy;
struct iio_channel_info *channels;
- while ((c = getopt(argc, argv, "c:egl:n:t:w:")) != -1) {
+ while ((c = getopt(argc, argv, "c:egl:n:t:w:m:")) != -1) {
switch (c) {
case 'c':
errno = 0;
@@ -251,6 +253,12 @@ int main(int argc, char **argv)
return -errno;
break;
+ case 'm':
+ errno = 0;
+ watermark = strtoul(optarg, &dummy, 10);
+ if (errno)
+ return -errno;
+ break;
case 'n':
device_name = optarg;
break;
@@ -371,6 +379,15 @@ int main(int argc, char **argv)
if (ret < 0)
goto error_free_buf_dir_name;
+ if (watermark) {
+ ret = write_sysfs_int("watermark", buf_dir_name,
+ watermark);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to write watermark\n");
+ goto error_free_buf_dir_name;
+ }
+ }
+
/* Enable the buffer */
ret = write_sysfs_int("enable", buf_dir_name, 1);
if (ret < 0) {
--
1.9.1
reply other threads:[~2016-04-26 15:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461683745-1006-1-git-send-email-doru.gucea@intel.com \
--to=doru.gucea@intel.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome