aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2015-09-14 17:13:48 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2015-09-14 17:13:48 +0200
commitf8236cb3eda9153ffb24da9fc3a34b8b9fdf9723 (patch)
treeade08086a8c77301f170634dd9c5f39886e8a772
parent7593bb6fc210bc5390433c3ab03aecb1176761a2 (diff)
Encapsulate the aep reset lines into a function
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--aep.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/aep.c b/aep.c
index c8a0b7b..2a048aa 100644
--- a/aep.c
+++ b/aep.c
@@ -373,6 +373,14 @@ static int aep_channel_setup(int fd, int channel)
return 0;
}
+static int aep_reset(int fd)
+{
+ if (aep_write_char(fd, AEP_RESET))
+ return -1;
+
+ return aep_read_magic(fd);
+}
+
int aep_config(int fd)
{
/*
@@ -385,10 +393,11 @@ int aep_config(int fd)
* Clear all channels, stop all captures, ...
* Magic number telling the probe is ready.
*/
- if (aep_write_char(fd, AEP_RESET))
- return -1;
-
- if (aep_read_magic(fd))
+ /*
+ * Clear all channels, stop all captures, ...
+ * Magic number telling the probe is ready.
+ */
+ if (aep_reset(fd))
return -1;
/*
@@ -770,7 +779,11 @@ again:
aep_print(aep_opt, dev, &frame[i], output);
}
- aep_stop(aep_dev.fd);
+ if (aep_stop(aep_dev.fd))
+ fprintf(stderr, "Failed to stop probe '%s'", aep_dev.name);
+
+ if (aep_reset(aep_dev.fd))
+ fprintf(stderr, "Failed to reset probe '%s'", aep_dev.name);
if (aep_dev.frame_missed)
fprintf(stderr, "%s missed %ld frames\n", aep_dev.name,