summaryrefslogtreecommitdiffstats
path: root/tools/iio
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 14:40:18 +0200
committerJonathan Cameron <jic23@kernel.org>2015-06-01 08:34:48 +0100
commit916e89e4b7272e1eda9eba057cf25197129bcf79 (patch)
tree799a0612f3386aa80d8563bf1aedd556c268eeef /tools/iio
parent0e799878175aa7d08f5882b6a391de4724c52e9e (diff)
downloadlinux-916e89e4b7272e1eda9eba057cf25197129bcf79.tar.bz2
tools:iio:iio_event_monitor: refactor events output
Refactor the code in print_event() to reduce code duplication and better reflect that the type is output unconditionally, as well as cascade the dependency of the diff-channel. Saves a few lines of code, as well. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r--tools/iio/iio_event_monitor.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 7f56238b1d66..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]);