Commit f8a26f05 authored by Edward Sheldrake's avatar Edward Sheldrake Committed by Mauro Carvalho Chehab

[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: default avatarEdward Sheldrake <ejsheldrake@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 133a9fe9
...@@ -889,10 +889,15 @@ static int ReadIFAgc(struct drxd_state *state, u32 * pValue) ...@@ -889,10 +889,15 @@ static int ReadIFAgc(struct drxd_state *state, u32 * pValue)
u32 R2 = state->if_agc_cfg.R2; u32 R2 = state->if_agc_cfg.R2;
u32 R3 = state->if_agc_cfg.R3; u32 R3 = state->if_agc_cfg.R3;
u32 Vmax = (3300 * R2) / (R1 + R2); u32 Vmax, Rpar, Vmin, Vout;
u32 Rpar = (R2 * R3) / (R3 + R2);
u32 Vmin = (3300 * Rpar) / (R1 + Rpar); if (R2 == 0 && (R1 == 0 || R3 == 0))
u32 Vout = Vmin + ((Vmax - Vmin) * Value) / 1024; 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; *pValue = Vout;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment