Skip to content

Commit

Permalink
[media] fc2580: fix tuning failure on 32-bit arch
Browse files Browse the repository at this point in the history
There was some frequency calculation overflows which caused tuning
failure on 32-bit architecture. Use 64-bit numbers where needed in
order to avoid calculation overflows.

Thanks for the Finnish person, who asked remain anonymous, reporting,
testing and suggesting the fix.

Cc: <stable@vger.kernel.org>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
  • Loading branch information
Antti Palosaari authored and Mauro Carvalho Chehab committed Apr 16, 2014
1 parent 877ed14 commit 8845cc6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/media/tuners/fc2580.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static int fc2580_set_params(struct dvb_frontend *fe)

f_ref = 2UL * priv->cfg->clock / r_val;
n_val = div_u64_rem(f_vco, f_ref, &k_val);
k_val_reg = 1UL * k_val * (1 << 20) / f_ref;
k_val_reg = div_u64(1ULL * k_val * (1 << 20), f_ref);

ret = fc2580_wr_reg(priv, 0x18, r18_val | ((k_val_reg >> 16) & 0xff));
if (ret < 0)
Expand Down Expand Up @@ -348,8 +348,8 @@ static int fc2580_set_params(struct dvb_frontend *fe)
if (ret < 0)
goto err;

ret = fc2580_wr_reg(priv, 0x37, 1UL * priv->cfg->clock * \
fc2580_if_filter_lut[i].mul / 1000000000);
ret = fc2580_wr_reg(priv, 0x37, div_u64(1ULL * priv->cfg->clock *
fc2580_if_filter_lut[i].mul, 1000000000));
if (ret < 0)
goto err;

Expand Down
1 change: 1 addition & 0 deletions drivers/media/tuners/fc2580_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define FC2580_PRIV_H

#include "fc2580.h"
#include <linux/math64.h>

struct fc2580_reg_val {
u8 reg;
Expand Down

0 comments on commit 8845cc6

Please sign in to comment.