From patchwork Thu Feb 7 16:19:30 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: 2112121 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 1299840106 for ; Thu, 7 Feb 2013 17:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759105Ab3BGRF6 (ORCPT ); Thu, 7 Feb 2013 12:05:58 -0500 Received: from bues.ch ([80.190.117.144]:33776 "EHLO bues.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759069Ab3BGRFp (ORCPT ); Thu, 7 Feb 2013 12:05:45 -0500 Received: by bues.ch with esmtpsa (Exim 4.72) (envelope-from ) id 1U3UF3-0006Uj-TS; Thu, 07 Feb 2013 17:22:30 +0100 Date: Thu, 7 Feb 2013 17:19:30 +0100 From: Michael =?UTF-8?B?QsO8c2No?= To: Mauro Carvalho Chehab Cc: linux-media Subject: [PATCH 3/4] fc0011: Add some sanity checks and cleanups Message-ID: <20130207171930.134fd97f@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 Add some sanity checks to the calculations and make the REG_16 register write consistent with the other ones. Signed-off-by: Michael Buesch Index: linux/drivers/media/tuners/fc0011.c =================================================================== --- linux.orig/drivers/media/tuners/fc0011.c 2012-10-22 16:15:46.000000000 +0200 +++ linux/drivers/media/tuners/fc0011.c 2012-10-22 16:17:15.280720317 +0200 @@ -220,6 +220,7 @@ /* Calc XIN. The PLL reference frequency is 18 MHz. */ xdiv = fvco / 18000; + WARN_ON(xdiv > 0xFF); frac = fvco - xdiv * 18000; frac = (frac << 15) / 18000; if (frac >= 16384) @@ -346,6 +347,8 @@ vco_cal &= FC11_VCOCAL_VALUEMASK; switch (vco_sel) { + default: + WARN_ON(1); case 0: if (vco_cal < 8) { regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2); @@ -427,7 +430,8 @@ err = fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]); if (err) return err; - err = fc0011_writereg(priv, FC11_REG_16, 0xB); + regs[FC11_REG_16] = 0xB; + err = fc0011_writereg(priv, FC11_REG_16, regs[FC11_REG_16]); if (err) return err;