From: "Gábor Stefanik" <netrolller.3d@gmail.com>
To: John Linville <linville@tuxdriver.com>,
Michael Buesch <mb@bu3sch.de>,
Larry Finger <Larry.Finger@lwfinger.net>,
Mark Huijgen <mark@huijgen.tk>
Cc: Broadcom Wireless <bcm43xx-dev@lists.berlios.de>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: [PATCH] b43: LP-PHY: Fix and simplify Qdiv roundup
Date: Tue, 25 Aug 2009 16:40:17 +0200 [thread overview]
Message-ID: <1251211217-7816-1-git-send-email-netrolller.3d@gmail.com> (raw)
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 <netrolller.3d@gmail.com>
---
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;
--
1.5.6
next reply other threads:[~2009-08-25 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-25 14:40 Gábor Stefanik [this message]
2009-08-25 15:09 ` [PATCH] b43: LP-PHY: Fix and simplify Qdiv roundup Bob Copeland
2009-08-25 20:48 ` Michael Buesch
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=1251211217-7816-1-git-send-email-netrolller.3d@gmail.com \
--to=netrolller.3d@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mark@huijgen.tk \
--cc=mb@bu3sch.de \
/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;
as well as URLs for NNTP newsgroup(s).