[media] fc0011: Fix xin value clamping

Fix the xin value clamping and use clamp_t().

Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Michael Büsch 2013-02-07 12:16:55 -03:00 committed by Mauro Carvalho Chehab
parent db5c05b2a1
commit 03a497d4b4
1 changed files with 2 additions and 7 deletions

View File

@ -183,8 +183,7 @@ static int fc0011_set_params(struct dvb_frontend *fe)
unsigned int i, vco_retries; unsigned int i, vco_retries;
u32 freq = p->frequency / 1000; u32 freq = p->frequency / 1000;
u32 bandwidth = p->bandwidth_hz / 1000; u32 bandwidth = p->bandwidth_hz / 1000;
u32 fvco, xin, xdiv, xdivr; u32 fvco, xin, frac, xdiv, xdivr;
u16 frac;
u8 fa, fp, vco_sel, vco_cal; u8 fa, fp, vco_sel, vco_cal;
u8 regs[FC11_NR_REGS] = { }; u8 regs[FC11_NR_REGS] = { };
@ -227,12 +226,8 @@ static int fc0011_set_params(struct dvb_frontend *fe)
frac += 32786; frac += 32786;
if (!frac) if (!frac)
xin = 0; xin = 0;
else if (frac < 511)
xin = 512;
else if (frac < 65026)
xin = frac;
else else
xin = 65024; xin = clamp_t(u32, frac, 512, 65024);
regs[FC11_REG_XINHI] = xin >> 8; regs[FC11_REG_XINHI] = xin >> 8;
regs[FC11_REG_XINLO] = xin; regs[FC11_REG_XINLO] = xin;