# HG changeset patch # User Daniele Nicolodi # Date 1434458016 -7200 # Node ID 6c748ed6a7c549bf1f0e33fc3d912cd75d283b77 # Parent 5296f3bcd1609fa83d85e9fff32853379f452353 Stricter error checks ad9912 ramp frequency function diff -r 5296f3bcd160 -r 6c748ed6a7c5 ad9912.c --- a/ad9912.c Tue Jun 16 14:31:35 2015 +0200 +++ b/ad9912.c Tue Jun 16 14:33:36 2015 +0200 @@ -92,26 +92,29 @@ */ int ad9912_ramp_frequency2(struct ad9912 *d, unsigned channel, double f1, double f2, double fstep) { + int r = 0; const int delay = 10000; /* f2 > f1 */ while ((f2 - f1) > fstep) { f1 += fstep; - ad9912_set_frequency(d, channel, f1); + r = ad9912_set_frequency(d, channel, f1); + if (r < 0) + return r; usleep(delay); } /* f2 < f1 */ while ((f1 - f2) > fstep) { f1 -= fstep; - ad9912_set_frequency(d, channel, f1); + r = ad9912_set_frequency(d, channel, f1); + if (r < 0) + return r; usleep(delay); } /* final adjustment */ - ad9912_set_frequency(d, channel, f2); - - return 0; + return ad9912_set_frequency(d, channel, f2); }