From patchwork Tue Aug 25 14:40:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?G=C3=A1bor_Stefanik?= X-Patchwork-Id: 43764 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7PEfE2h007355 for ; Tue, 25 Aug 2009 14:41:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755244AbZHYOkU (ORCPT ); Tue, 25 Aug 2009 10:40:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755242AbZHYOkT (ORCPT ); Tue, 25 Aug 2009 10:40:19 -0400 Received: from mail-ew0-f206.google.com ([209.85.219.206]:55477 "EHLO mail-ew0-f206.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755241AbZHYOkS (ORCPT ); Tue, 25 Aug 2009 10:40:18 -0400 Received: by ewy2 with SMTP id 2so490055ewy.17 for ; Tue, 25 Aug 2009 07:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:mime-version:content-type :content-transfer-encoding; bh=c+DqAZ5nwKGWi24qdFlsMafGz+p6Vngt8dS7XUpQ+5o=; b=tCeivY9XtcmD6rZ4PIltwLh/4+S52vBtbYmXcZigI51hvyc0Lqmodzhf0YysfJ+mu4 bcnzvuA3d2xZmeN9Y2wYgPr4bU/OmnY6DXBI0ngCWFvuEMYsbp+TZfPmJvFscgAe1byR nNMwTmG6yZ3RJaf57I8YzF675eLbZQaR8RR8s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; b=d4KrkfdYqCgD30sty4c938ol7v+yeMiDyJYGG5qg5NgUOu/OpuyGZi2INLZkRHtsWK WoC9koqIEzzQcPbx7uVAjW5gp8VbDVpTw4bqiqcxEkXvvecTcZgmmkXDEtDu+xrq1ZKV EiJMpk6wd2mk0Efjff0ziz/NIZvwWccW3//nY= Received: by 10.103.50.32 with SMTP id c32mr2761028muk.1.1251211219045; Tue, 25 Aug 2009 07:40:19 -0700 (PDT) Received: from localhost (pool-017a6.externet.hu [88.209.193.165]) by mx.google.com with ESMTPS id s11sm107265mue.11.2009.08.25.07.40.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 25 Aug 2009 07:40:18 -0700 (PDT) From: =?utf-8?q?G=C3=A1bor=20Stefanik?= To: John Linville , Michael Buesch , Larry Finger , Mark Huijgen Cc: Broadcom Wireless , linux-wireless Subject: [PATCH] b43: LP-PHY: Fix and simplify Qdiv roundup Date: Tue, 25 Aug 2009 16:40:17 +0200 Message-Id: <1251211217-7816-1-git-send-email-netrolller.3d@gmail.com> X-Mailer: git-send-email 1.5.6 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The Qdiv roundup routine is essentially a fixed-point division algorithm, using only integer math. However, the version in the specs had a major error that has been recently fixed (a missing quotient++). Replace Qdiv roundup with a rewritten, simplified version. Signed-off-by: Gábor Stefanik --- drivers/net/wireless/b43/phy_lp.c | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index 7e70c07..d0280d5 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c @@ -1034,7 +1034,7 @@ static int lpphy_loopback(struct b43_wldev *dev) static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) { - u32 quotient, remainder, rbit, roundup, tmp; + u32 quotient, remainder; if (divisor == 0) return 0; @@ -1042,20 +1042,14 @@ static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) quotient = dividend / divisor; remainder = dividend % divisor; - rbit = divisor & 0x1; - roundup = (divisor >> 1) + rbit; - while (precision != 0) { - tmp = remainder - roundup; quotient <<= 1; - if (remainder >= roundup) - remainder = (tmp << 1) + rbit; - else - remainder <<= 1; + quotient |= (remainder << 1) / divisor; + remainder = (remainder << 1) % divisor; precision--; } - if (remainder >= roundup) + if (remainder << 1 >= divisor) quotient++; return quotient;