summaryrefslogtreecommitdiffstats
path: root/tools/iio
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 08:40:18 -0400
committerJonathan Cameron <jic23@kernel.org>2015-06-01 03:34:48 -0400
commit916e89e4b7272e1eda9eba057cf25197129bcf79 (patch)
tree799a0612f3386aa80d8563bf1aedd556c268eeef /tools/iio
parent0e799878175aa7d08f5882b6a391de4724c52e9e (diff)
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)
213 return; 213 return;
214 } 214 }
215 215
216 printf("Event: time: %lld, ", event->timestamp); 216 printf("Event: time: %lld, type: %s", event->timestamp,
217 iio_chan_type_name_spec[type]);
217 218
218 if (mod != IIO_NO_MOD) { 219 if (mod != IIO_NO_MOD)
219 printf("type: %s(%s), ", 220 printf("(%s)", iio_modifier_names[mod]);
220 iio_chan_type_name_spec[type],
221 iio_modifier_names[mod]);
222 } else {
223 printf("type: %s, ",
224 iio_chan_type_name_spec[type]);
225 }
226 221
227 if (diff && chan >= 0 && chan2 >= 0) 222 if (chan >= 0) {
228 printf("channel: %d-%d, ", chan, chan2); 223 printf(", channel: %d", chan);
229 else if (chan >= 0) 224 if (diff && chan2 >= 0)
230 printf("channel: %d, ", chan); 225 printf("-%d", chan2);
226 }
231 227
232 printf("evtype: %s", iio_ev_type_text[ev_type]); 228 printf(", evtype: %s", iio_ev_type_text[ev_type]);
233 229
234 if (dir != IIO_EV_DIR_NONE) 230 if (dir != IIO_EV_DIR_NONE)
235 printf(", direction: %s", iio_ev_dir_text[dir]); 231 printf(", direction: %s", iio_ev_dir_text[dir]);