From patchwork Fri Dec 31 11:37:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Igor M. Liplianin" X-Patchwork-Id: 442871 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p019WcH5010888 for ; Sat, 1 Jan 2011 09:32:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025Ab1AAJcK (ORCPT ); Sat, 1 Jan 2011 04:32:10 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:44191 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676Ab1AAJcJ (ORCPT ); Sat, 1 Jan 2011 04:32:09 -0500 Received: by eye27 with SMTP id 27so5457979eye.19 for ; Sat, 01 Jan 2011 01:32:08 -0800 (PST) Received: by 10.213.14.2 with SMTP id e2mr15675279eba.6.1293874328072; Sat, 01 Jan 2011 01:32:08 -0800 (PST) Received: from useri.localnet ([93.125.74.3]) by mx.google.com with ESMTPS id q58sm12964940eeh.9.2011.01.01.01.32.06 (version=SSLv3 cipher=RC4-MD5); Sat, 01 Jan 2011 01:32:07 -0800 (PST) Message-ID: <4d1ef497.52790e0a.1192.06a8@mx.google.com> From: "Igor M. Liplianin" Date: Fri, 31 Dec 2010 13:37:00 +0200 Subject: [PATCH 09/18] stv0367: Fix potential divide error To: , , Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 01 Jan 2011 09:32:43 +0000 (UTC) diff --git a/drivers/media/dvb/frontends/stv0367.c b/drivers/media/dvb/frontends/stv0367.c index 0575741..e6bee7f 100644 --- a/drivers/media/dvb/frontends/stv0367.c +++ b/drivers/media/dvb/frontends/stv0367.c @@ -3275,12 +3275,14 @@ static int stv0367cab_read_snr(struct dvb_frontend *fe, u16 *snr) power = 1; break; } + for (i = 0; i < 10; i++) { regval += (stv0367_readbits(state, F367CAB_SNR_LO) + 256 * stv0367_readbits(state, F367CAB_SNR_HI)); } + + regval /= 10; /*for average over 10 times in for loop above*/ if (regval != 0) { - regval /= 10; /*for average over 10 times in for loop above*/ temp = power * (1 << (3 + stv0367_readbits(state, F367CAB_SNR_PER))); temp /= regval;