[media] tuner-core: handle errors when getting signal strength/afc
authorMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 25 Mar 2013 12:55:59 +0000 (09:55 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 25 Mar 2013 18:10:43 +0000 (15:10 -0300)
If those callbacks fail, it should return zero, and not a random
value. The previous code assumed that all drivers would only change
signal strength if it succeeds, but this may not be true.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/v4l2-core/tuner-core.c

index f1e8b402b7cab65ddbe848bef1c4d88b885d517b..cf9a9af903220b9ce576d93b14ed4184e9d34a59 100644 (file)
@@ -220,18 +220,20 @@ static void fe_standby(struct dvb_frontend *fe)
 
 static int fe_has_signal(struct dvb_frontend *fe)
 {
-       u16 strength = 0;
+       u16 strength;
 
-       fe->ops.tuner_ops.get_rf_strength(fe, &strength);
+       if (fe->ops.tuner_ops.get_rf_strength(fe, &strength) < 0)
+               return 0;
 
        return strength;
 }
 
 static int fe_get_afc(struct dvb_frontend *fe)
 {
-       s32 afc = 0;
+       s32 afc;
 
-       fe->ops.tuner_ops.get_afc(fe, &afc);
+       if (fe->ops.tuner_ops.get_afc(fe, &afc) < 0)
+               return 0;
 
        return afc;
 }