diff options
author | Edward Sheldrake <ejsheldrake@gmail.com> | 2011-08-26 17:59:30 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-09-04 16:17:11 +0200 |
commit | f8a26f052a5f62c7555d09680c1fe8cbfcac590f (patch) | |
tree | 43bf0081837d7872f0ef6c486164afb1166c9ee8 | |
parent | [media] gspca: Use current logging styles (diff) | |
download | linux-f8a26f052a5f62c7555d09680c1fe8cbfcac590f.tar.xz linux-f8a26f052a5f62c7555d09680c1fe8cbfcac590f.zip |
[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.c | 13 |
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) u32 R2 = state->if_agc_cfg.R2; u32 R3 = state->if_agc_cfg.R3; - u32 Vmax = (3300 * R2) / (R1 + R2); - u32 Rpar = (R2 * R3) / (R3 + R2); - u32 Vmin = (3300 * Rpar) / (R1 + Rpar); - u32 Vout = Vmin + ((Vmax - Vmin) * Value) / 1024; + u32 Vmax, Rpar, Vmin, Vout; + + if (R2 == 0 && (R1 == 0 || R3 == 0)) + return 0; + + Vmax = (3300 * R2) / (R1 + R2); + Rpar = (R2 * R3) / (R3 + R2); + Vmin = (3300 * Rpar) / (R1 + Rpar); + Vout = Vmin + ((Vmax - Vmin) * Value) / 1024; *pValue = Vout; } |