diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-09-14 17:13:48 +0200 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2015-09-14 17:13:48 +0200 |
commit | f8236cb3eda9153ffb24da9fc3a34b8b9fdf9723 (patch) | |
tree | ade08086a8c77301f170634dd9c5f39886e8a772 | |
parent | 7593bb6fc210bc5390433c3ab03aecb1176761a2 (diff) |
Encapsulate the aep reset lines into a function
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r-- | aep.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -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, |