[PATCH] save gain only when set_gain is successful

Joseph Poirier jdpoirier at gmail.com
Sun Nov 29 03:00:19 UTC 2015


Signed-off-by: Joseph Poirier <jdpoirier at gmail.com>
---
 src/librtlsdr.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index cdf1ca9..fd435b7 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1038,13 +1038,10 @@ int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain)
 		rtlsdr_set_i2c_repeater(dev, 1);
 		r = dev->tuner->set_gain((void *)dev, gain);
 		rtlsdr_set_i2c_repeater(dev, 0);
+		if (!r)
+			dev->gain = gain;
 	}
 
-	if (!r)
-		dev->gain = gain;
-	else
-		dev->gain = 0;
-
 	return r;
 }
 
-- 
2.5.0




More information about the osmocom-sdr mailing list