diff options
Diffstat (limited to 'drivers/media/dvb/frontends/stv6110x.c')
-rw-r--r-- | drivers/media/dvb/frontends/stv6110x.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/media/dvb/frontends/stv6110x.c b/drivers/media/dvb/frontends/stv6110x.c index 3d8a2e01c9c4..bcfcb652464c 100644 --- a/drivers/media/dvb/frontends/stv6110x.c +++ b/drivers/media/dvb/frontends/stv6110x.c | |||
@@ -95,7 +95,7 @@ static int stv6110x_set_frequency(struct dvb_frontend *fe, u32 frequency) | |||
95 | { | 95 | { |
96 | struct stv6110x_state *stv6110x = fe->tuner_priv; | 96 | struct stv6110x_state *stv6110x = fe->tuner_priv; |
97 | u32 rDiv, divider; | 97 | u32 rDiv, divider; |
98 | s32 pVal, pCalc, rDivOpt = 0; | 98 | s32 pVal, pCalc, rDivOpt = 0, pCalcOpt = 1000; |
99 | u8 i; | 99 | u8 i; |
100 | 100 | ||
101 | STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16)); | 101 | STV6110x_SETFIELD(stv6110x_regs[STV6110x_CTRL1], CTRL1_K, (REFCLOCK_MHz - 16)); |
@@ -121,8 +121,10 @@ static int stv6110x_set_frequency(struct dvb_frontend *fe, u32 frequency) | |||
121 | for (rDiv = 0; rDiv <= 3; rDiv++) { | 121 | for (rDiv = 0; rDiv <= 3; rDiv++) { |
122 | pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv); | 122 | pCalc = (REFCLOCK_kHz / 100) / R_DIV(rDiv); |
123 | 123 | ||
124 | if ((abs((s32)(pCalc - pVal))) < (abs((s32)(1000 - pVal)))) | 124 | if ((abs((s32)(pCalc - pVal))) < (abs((s32)(pCalcOpt - pVal)))) |
125 | rDivOpt = rDiv; | 125 | rDivOpt = rDiv; |
126 | |||
127 | pCalcOpt = (REFCLOCK_kHz / 100) / R_DIV(rDivOpt); | ||
126 | } | 128 | } |
127 | 129 | ||
128 | divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz; | 130 | divider = (frequency * R_DIV(rDivOpt) * pVal) / REFCLOCK_kHz; |