Skip to content

Commit

Permalink
[media] fc0011: Add some sanity checks and cleanups
Browse files Browse the repository at this point in the history
Add some sanity checks to the calculations and make the REG_16 register write consistent
with the other ones.

Signed-off-by: Michael Buesch <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
mbuesch authored and Mauro Carvalho Chehab committed Feb 8, 2013
1 parent 03a497d commit aadb464
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/media/tuners/fc0011.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ static int fc0011_set_params(struct dvb_frontend *fe)

/* Calc XIN. The PLL reference frequency is 18 MHz. */
xdiv = fvco / 18000;
WARN_ON(xdiv > 0xFF);
frac = fvco - xdiv * 18000;
frac = (frac << 15) / 18000;
if (frac >= 16384)
Expand Down Expand Up @@ -346,6 +347,8 @@ static int fc0011_set_params(struct dvb_frontend *fe)
vco_cal &= FC11_VCOCAL_VALUEMASK;

switch (vco_sel) {
default:
WARN_ON(1);
case 0:
if (vco_cal < 8) {
regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
Expand Down Expand Up @@ -427,7 +430,8 @@ static int fc0011_set_params(struct dvb_frontend *fe)
err = fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
if (err)
return err;
err = fc0011_writereg(priv, FC11_REG_16, 0xB);
regs[FC11_REG_16] = 0xB;
err = fc0011_writereg(priv, FC11_REG_16, regs[FC11_REG_16]);
if (err)
return err;

Expand Down

0 comments on commit aadb464

Please sign in to comment.