aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Sheldrake <ejsheldrake@gmail.com>2011-08-26 11:59:30 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-09-04 10:17:11 -0400
commitf8a26f052a5f62c7555d09680c1fe8cbfcac590f (patch)
tree43bf0081837d7872f0ef6c486164afb1166c9ee8
parent133a9fe949862d9ed8411fb423739f4cee08232d (diff)
[media] drxd: fix divide error
Fix division by zero in drxd triggered by running "femon" before any DVB tuning has been done (by "scandvb" or anything else). Signed-off-by: Edward Sheldrake <ejsheldrake@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/frontends/drxd_hard.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/media/dvb/frontends/drxd_hard.c b/drivers/media/dvb/frontends/drxd_hard.c
index 2238bf0be959..bcad01ca1a13 100644
--- a/drivers/media/dvb/frontends/drxd_hard.c
+++ b/drivers/media/dvb/frontends/drxd_hard.c
@@ -889,10 +889,15 @@ static int ReadIFAgc(struct drxd_state *state, u32 * pValue)
889 u32 R2 = state->if_agc_cfg.R2; 889 u32 R2 = state->if_agc_cfg.R2;
890 u32 R3 = state->if_agc_cfg.R3; 890 u32 R3 = state->if_agc_cfg.R3;
891 891
892 u32 Vmax = (3300 * R2) / (R1 + R2); 892 u32 Vmax, Rpar, Vmin, Vout;
893 u32 Rpar = (R2 * R3) / (R3 + R2); 893
894 u32 Vmin = (3300 * Rpar) / (R1 + Rpar); 894 if (R2 == 0 && (R1 == 0 || R3 == 0))
895 u32 Vout = Vmin + ((Vmax - Vmin) * Value) / 1024; 895 return 0;
896
897 Vmax = (3300 * R2) / (R1 + R2);
898 Rpar = (R2 * R3) / (R3 + R2);
899 Vmin = (3300 * Rpar) / (R1 + Rpar);
900 Vout = Vmin + ((Vmax - Vmin) * Value) / 1024;
896 901
897 *pValue = Vout; 902 *pValue = Vout;
898 } 903 }