diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-26 15:46:08 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-26 15:46:08 -0700 |
commit | 23908db413eccd77084b09c9b0a4451dfb0524c0 (patch) | |
tree | 646f21a92496bdc04175e95642b0ecb2dc3dd09e /tools/iio/iio_event_monitor.c | |
parent | 8d7804a2f03dbd34940fcb426450c730adf29dae (diff) | |
parent | 53a20e9e378ecd52f0afa4b60f8f8c81b6f97c27 (diff) |
Merge tag 'staging-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging driver updates from Greg KH:
"Here's the big, really big, staging tree patches for 4.2-rc1.
Loads of stuff in here, almost all just coding style fixes / churn,
and a few new drivers as well, one of which I just disabled from the
build a few minutes ago due to way too many build warnings.
Other than the one "disable this driver" patch, all of these have been
in linux-next for quite a while with no reported issues"
* tag 'staging-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1163 commits)
staging: wilc1000: disable driver due to build warnings
Staging: rts5208: fix CHANGE_LINK_STATE value
Staging: sm750fb: ddk750_swi2c.c: Insert spaces before parenthesis
Staging: sm750fb: ddk750_swi2c.c: Place braces on correct lines
Staging: sm750fb: ddk750_swi2c.c: Insert spaces around operators
Staging: sm750fb: ddk750_swi2c.c: Replace spaces with tabs
Staging: sm750fb: ddk750_swi2c.h: Shorten lines to under 80 characters
Staging: sm750fb: ddk750_swi2c.h: Replace spaces with tabs
Staging: sm750fb: modedb.h: Shorten lines to under 80 characters
Staging: sm750fb: modedb.h: Replace spaces with tabs
staging: comedi: addi_apci_3120: rename 'this_board' variables
staging: comedi: addi_apci_1516: rename 'this_board' variables
staging: comedi: ni_atmio: cleanup ni_getboardtype()
staging: comedi: vmk80xx: sanity check context used to get the boardinfo
staging: comedi: vmk80xx: rename 'boardinfo' variables
staging: comedi: dt3000: rename 'this_board' variables
staging: comedi: adv_pci_dio: rename 'this_board' variables
staging: comedi: cb_pcidas64: rename 'thisboard' variables
staging: comedi: cb_pcidas: rename 'thisboard' variables
staging: comedi: me4000: rename 'thisboard' variables
...
Diffstat (limited to 'tools/iio/iio_event_monitor.c')
-rw-r--r-- | tools/iio/iio_event_monitor.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c index 427c271ac0d6..016760e769c0 100644 --- a/tools/iio/iio_event_monitor.c +++ b/tools/iio/iio_event_monitor.c @@ -213,23 +213,19 @@ static void print_event(struct iio_event_data *event) return; } - printf("Event: time: %lld, ", event->timestamp); + printf("Event: time: %lld, type: %s", event->timestamp, + iio_chan_type_name_spec[type]); - if (mod != IIO_NO_MOD) { - printf("type: %s(%s), ", - iio_chan_type_name_spec[type], - iio_modifier_names[mod]); - } else { - printf("type: %s, ", - iio_chan_type_name_spec[type]); - } + if (mod != IIO_NO_MOD) + printf("(%s)", iio_modifier_names[mod]); - if (diff && chan >= 0 && chan2 >= 0) - printf("channel: %d-%d, ", chan, chan2); - else if (chan >= 0) - printf("channel: %d, ", chan); + if (chan >= 0) { + printf(", channel: %d", chan); + if (diff && chan2 >= 0) + printf("-%d", chan2); + } - printf("evtype: %s", iio_ev_type_text[ev_type]); + printf(", evtype: %s", iio_ev_type_text[ev_type]); if (dir != IIO_EV_DIR_NONE) printf(", direction: %s", iio_ev_dir_text[dir]); @@ -258,28 +254,34 @@ int main(int argc, char **argv) device_name, dev_num); ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num); if (ret < 0) { - ret = -ENOMEM; - goto error_ret; + return -ENOMEM; } } else { /* If we can't find a IIO device by name assume device_name is a IIO chrdev */ chrdev_name = strdup(device_name); + if (!chrdev_name) + return -ENOMEM; } fd = open(chrdev_name, 0); if (fd == -1) { - fprintf(stdout, "Failed to open %s\n", chrdev_name); ret = -errno; + fprintf(stdout, "Failed to open %s\n", chrdev_name); goto error_free_chrdev_name; } ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd); - - close(fd); - if (ret == -1 || event_fd == -1) { + ret = -errno; fprintf(stdout, "Failed to retrieve event fd\n"); + if (close(fd) == -1) + perror("Failed to close character device file"); + + goto error_free_chrdev_name; + } + + if (close(fd) == -1) { ret = -errno; goto error_free_chrdev_name; } @@ -291,8 +293,8 @@ int main(int argc, char **argv) printf("nothing available\n"); continue; } else { - perror("Failed to read event from device"); ret = -errno; + perror("Failed to read event from device"); break; } } @@ -300,9 +302,11 @@ int main(int argc, char **argv) print_event(&event); } - close(event_fd); + if (close(event_fd) == -1) + perror("Failed to close event file"); + error_free_chrdev_name: free(chrdev_name); -error_ret: + return ret; } |