Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30268a3d authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman
Browse files

staging:iio: update example to handle case with no ring events

parent b949793b
Loading
Loading
Loading
Loading
+29 −16
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <sys/dir.h>
#include <linux/types.h>
#include <string.h>
#include "iio_utils.h"

const int buf_len = 128;
@@ -134,10 +135,11 @@ int main(int argc, char **argv)
	int dev_num, trig_num;
	char *buffer_access, *buffer_event;
	int scan_size;
	int noevents = 0;

	struct iio_channel_info *infoarray;

	while ((c = getopt(argc, argv, "t:n:")) != -1) {
	while ((c = getopt(argc, argv, "et:n:")) != -1) {
		switch (c) {
		case 'n':
			device_name = optarg;
@@ -146,6 +148,9 @@ int main(int argc, char **argv)
			trigger_name = optarg;
			datardytrigger = 0;
			break;
		case 'e':
			noevents = 1;
			break;
		case '?':
			return -1;
		}
@@ -260,7 +265,10 @@ int main(int argc, char **argv)

	/* Wait for events 10 times */
	for (j = 0; j < num_loops; j++) {
		read_size = fread(&dat, 1, sizeof(struct iio_event_data),
		if (!noevents) {
			read_size = fread(&dat,
					1,
					sizeof(struct iio_event_data),
					fp_ev);
			switch (dat.id) {
			case IIO_EVENT_CODE_RING_100_FULL:
@@ -276,6 +284,11 @@ int main(int argc, char **argv)
				printf("Unexpecteded event code\n");
				continue;
			}
		} else {
			usleep(1000);
			toread = 64;
		}

		read_size = read(fp,
				 data,
				 toread*scan_size);