public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] fc0011: Fix xin value clamping
@ 2013-02-07 16:16 Michael Büsch
  0 siblings, 0 replies; only message in thread
From: Michael Büsch @ 2013-02-07 16:16 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

Fix the xin value clamping and use clamp_t().

Signed-off-by: Michael Buesch <m@bues.ch>

---

Index: linux/drivers/media/tuners/fc0011.c
===================================================================
--- linux.orig/drivers/media/tuners/fc0011.c	2012-10-22 16:13:29.140465225 +0200
+++ linux/drivers/media/tuners/fc0011.c	2012-10-22 16:15:46.915056243 +0200
@@ -183,8 +183,7 @@
 	unsigned int i, vco_retries;
 	u32 freq = p->frequency / 1000;
 	u32 bandwidth = p->bandwidth_hz / 1000;
-	u32 fvco, xin, xdiv, xdivr;
-	u16 frac;
+	u32 fvco, xin, frac, xdiv, xdivr;
 	u8 fa, fp, vco_sel, vco_cal;
 	u8 regs[FC11_NR_REGS] = { };
 
@@ -227,12 +226,8 @@
 		frac += 32786;
 	if (!frac)
 		xin = 0;
-	else if (frac < 511)
-		xin = 512;
-	else if (frac < 65026)
-		xin = frac;
 	else
-		xin = 65024;
+		xin = clamp_t(u32, frac, 512, 65024);
 	regs[FC11_REG_XINHI] = xin >> 8;
 	regs[FC11_REG_XINLO] = xin;
 


-- 
Greetings, Michael.

PGP: 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-07 17:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-07 16:16 [PATCH 2/4] fc0011: Fix xin value clamping Michael Büsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox