From 598582c26a877b5135f9b6dbc47a185e3ed9b151 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 13 Apr 2011 13:47:41 -0300 Subject: [PATCH] atrf-path.c (do_half_sweep, do_sweep): don't duplicate the loop - use a function --- tools/atrf-path/atrf-path.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/atrf-path/atrf-path.c b/tools/atrf-path/atrf-path.c index 35ac963..a1e0e96 100644 --- a/tools/atrf-path/atrf-path.c +++ b/tools/atrf-path/atrf-path.c @@ -106,29 +106,26 @@ static void sample(const struct sweep *sweep, int cont_tx, } -void do_sweep(const struct sweep *sweep, struct sample *res) +static void do_half_sweep(const struct sweep *sweep, int cont_tx, + struct sample *res) { - struct sample *r; int chan; - r = res; for (chan = 11; chan <= 26; chan++) { set_channel(sweep->rx, chan); set_channel(sweep->tx, chan); usleep(155); /* table 7-2, tTR19 */ - sample(sweep, CONT_TX_M500K, r, chan == 11); - r += 2; + sample(sweep, cont_tx, res, chan == 11); + res += 2; } - r = res+1; - for (chan = 11; chan <= 26; chan++) { - set_channel(sweep->rx, chan); - set_channel(sweep->tx, chan); - usleep(155); /* table 7-2, tTR19 */ +} - sample(sweep, CONT_TX_P500K, r, chan == 11); - r += 2; - } + +void do_sweep(const struct sweep *sweep, struct sample *res) +{ + do_half_sweep(sweep, CONT_TX_M500K, res); + do_half_sweep(sweep, CONT_TX_P500K, res+1); }