public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Büsch" <m@bues.ch>
To: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: linux-media <linux-media@vger.kernel.org>
Subject: [PATCH 2/4] fc0011: Fix xin value clamping
Date: Thu, 7 Feb 2013 17:16:55 +0100	[thread overview]
Message-ID: <20130207171655.4243e21f@milhouse> (raw)

[-- 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 --]

                 reply	other threads:[~2013-02-07 17:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130207171655.4243e21f@milhouse \
    --to=m@bues.ch \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox