From patchwork Thu Feb 7 16:16:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michael_B=C3=BCsch?= X-Patchwork-Id: 2112131 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3628B40134 for ; Thu, 7 Feb 2013 17:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759111Ab3BGRGD (ORCPT ); Thu, 7 Feb 2013 12:06:03 -0500 Received: from bues.ch ([80.190.117.144]:33775 "EHLO bues.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759047Ab3BGRFo (ORCPT ); Thu, 7 Feb 2013 12:05:44 -0500 Received: by bues.ch with esmtpsa (Exim 4.72) (envelope-from ) id 1U3UF0-0006Uj-Nu; Thu, 07 Feb 2013 17:22:27 +0100 Date: Thu, 7 Feb 2013 17:16:55 +0100 From: Michael =?UTF-8?B?QsO8c2No?= To: Mauro Carvalho Chehab Cc: linux-media Subject: [PATCH 2/4] fc0011: Fix xin value clamping Message-ID: <20130207171655.4243e21f@milhouse> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fix the xin value clamping and use clamp_t(). Signed-off-by: Michael Buesch 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;