提交 03a497d4 编写于 作者: M Michael Büsch 提交者: Mauro Carvalho Chehab

[media] fc0011: Fix xin value clamping

Fix the xin value clamping and use clamp_t().
Signed-off-by: NMichael Buesch <m@bues.ch>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 db5c05b2
...@@ -183,8 +183,7 @@ static int fc0011_set_params(struct dvb_frontend *fe) ...@@ -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) ...@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册