Commit b6d5be57 authored by Karol Wrona's avatar Karol Wrona Committed by Jonathan Cameron

staging: iio: Add notrigger mode for generic_buffer

Some IIO devices do not use the triggers. This patch makes trigger setting
conditional so generic_buffer can be used when triggers are disabled.
Signed-off-by: default avatarKarol Wrona <k.wrona@samsung.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 455f0049
...@@ -158,11 +158,12 @@ int main(int argc, char **argv) ...@@ -158,11 +158,12 @@ int main(int argc, char **argv)
char *buffer_access; char *buffer_access;
int scan_size; int scan_size;
int noevents = 0; int noevents = 0;
int notrigger = 0;
char *dummy; char *dummy;
struct iio_channel_info *channels; struct iio_channel_info *channels;
while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) { while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
switch (c) { switch (c) {
case 'n': case 'n':
device_name = optarg; device_name = optarg;
...@@ -183,6 +184,9 @@ int main(int argc, char **argv) ...@@ -183,6 +184,9 @@ int main(int argc, char **argv)
case 'l': case 'l':
buf_len = strtoul(optarg, &dummy, 10); buf_len = strtoul(optarg, &dummy, 10);
break; break;
case 'g':
notrigger = 1;
break;
case '?': case '?':
return -1; return -1;
} }
...@@ -201,28 +205,32 @@ int main(int argc, char **argv) ...@@ -201,28 +205,32 @@ int main(int argc, char **argv)
printf("iio device number being used is %d\n", dev_num); printf("iio device number being used is %d\n", dev_num);
asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
if (trigger_name == NULL) {
/* if (!notrigger) {
* Build the trigger name. If it is device associated its if (trigger_name == NULL) {
* name is <device_name>_dev[n] where n matches the device /*
* number found above * Build the trigger name. If it is device associated
*/ * its name is <device_name>_dev[n] where n matches
ret = asprintf(&trigger_name, * the device number found above.
"%s-dev%d", device_name, dev_num); */
if (ret < 0) { ret = asprintf(&trigger_name,
ret = -ENOMEM; "%s-dev%d", device_name, dev_num);
goto error_ret; if (ret < 0) {
ret = -ENOMEM;
goto error_ret;
}
} }
}
/* Verify the trigger exists */ /* Verify the trigger exists */
trig_num = find_type_by_name(trigger_name, "trigger"); trig_num = find_type_by_name(trigger_name, "trigger");
if (trig_num < 0) { if (trig_num < 0) {
printf("Failed to find the trigger %s\n", trigger_name); printf("Failed to find the trigger %s\n", trigger_name);
ret = -ENODEV; ret = -ENODEV;
goto error_free_triggername; goto error_free_triggername;
} }
printf("iio trigger number being used is %d\n", trig_num); printf("iio trigger number being used is %d\n", trig_num);
} else
printf("trigger-less mode selected\n");
/* /*
* Parse the files in scan_elements to identify what channels are * Parse the files in scan_elements to identify what channels are
...@@ -246,14 +254,18 @@ int main(int argc, char **argv) ...@@ -246,14 +254,18 @@ int main(int argc, char **argv)
ret = -ENOMEM; ret = -ENOMEM;
goto error_free_triggername; goto error_free_triggername;
} }
printf("%s %s\n", dev_dir_name, trigger_name);
/* Set the device trigger to be the data ready trigger found above */ if (!notrigger) {
ret = write_sysfs_string_and_verify("trigger/current_trigger", printf("%s %s\n", dev_dir_name, trigger_name);
dev_dir_name, /* Set the device trigger to be the data ready trigger found
trigger_name); * above */
if (ret < 0) { ret = write_sysfs_string_and_verify("trigger/current_trigger",
printf("Failed to write current_trigger file\n"); dev_dir_name,
goto error_free_buf_dir_name; trigger_name);
if (ret < 0) {
printf("Failed to write current_trigger file\n");
goto error_free_buf_dir_name;
}
} }
/* Setup ring buffer parameters */ /* Setup ring buffer parameters */
...@@ -323,9 +335,10 @@ int main(int argc, char **argv) ...@@ -323,9 +335,10 @@ int main(int argc, char **argv)
if (ret < 0) if (ret < 0)
goto error_close_buffer_access; goto error_close_buffer_access;
/* Disconnect the trigger - just write a dummy name. */ if (!notrigger)
write_sysfs_string("trigger/current_trigger", /* Disconnect the trigger - just write a dummy name. */
dev_dir_name, "NULL"); write_sysfs_string("trigger/current_trigger",
dev_dir_name, "NULL");
error_close_buffer_access: error_close_buffer_access:
close(fp); close(fp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment