Skip to content

Commit 466b705

Browse files
ribaldahverkuil
authored andcommitted
media: dvb-frontends: tda10048: Make the range of z explicit.
The datasheet recommends 55MHz frequency sampling, with a max of 69 MHz. (Kudos to Kosta Stefanov for the calculations). Replace z with a 32 bit uint, and make the range of the variable explicit. Found by cocci: drivers/media/dvb-frontends/tda10048.c:345:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Reviewed-by: Kosta Stefanov <costa.stephanoff@gmail.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
1 parent f883f34 commit 466b705

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/media/dvb-frontends/tda10048.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz,
328328
u32 bw)
329329
{
330330
struct tda10048_state *state = fe->demodulator_priv;
331-
u64 t, z;
331+
u64 t;
332+
u32 z;
332333

333334
dprintk(1, "%s()\n", __func__);
334335

@@ -341,6 +342,11 @@ static int tda10048_set_wref(struct dvb_frontend *fe, u32 sample_freq_hz,
341342
/* t *= 2147483648 on 32bit platforms */
342343
t *= (2048 * 1024);
343344
t *= 1024;
345+
346+
/*
347+
* Sample frequency is typically 55 MHz, with a theoretical maximum of
348+
* 69 MHz. With a 32 bit z we have enough accuracy for up to 613 MHz.
349+
*/
344350
z = 7 * sample_freq_hz;
345351
do_div(t, z);
346352
t += 5;

0 commit comments

Comments
 (0)