From: Harvey Harrison <harvey.harrison@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: [PATCH 4/5] b43: Organize cases in radio2050_rfover_val
Date: Mon, 17 Mar 2008 17:47:30 -0700 [thread overview]
Message-ID: <1205801250.2329.53.camel@brick> (raw)
This function has three independant states that are looked at
phy_register: B43_PHY_RFOVER, B43_PHY_RFOVERVAL
lb_gain: has_loopback_gain(phy)
phy_lna: (phy->rev < 7) || !(sprom->boardflags_lo & B43_BFL_EXTLNA)
The B43_PHY_RFOVER case depends only on the phy_lna value, make this
test explicit.
The B43_PHY_RFOVERVAL case depends on both lb_gain and phy_lna.
Move the calculation of extlna before the if blocks and pull up an
adjustment that depends on phy_lna out of the switch statements.
Consolidate the switch statements using a conditional on phy_lna.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
drivers/net/wireless/b43/phy.c | 133 ++++++++++++++--------------------------
1 files changed, 46 insertions(+), 87 deletions(-)
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c
index bac54bb..0e2b065 100644
--- a/drivers/net/wireless/b43/phy.c
+++ b/drivers/net/wireless/b43/phy.c
@@ -3329,22 +3329,28 @@ static void radio2050_rfover_val(struct b43_wldev *dev,
{
struct b43_phy *phy = &dev->phy;
struct ssb_sprom *sprom = &(dev->dev->bus->sprom);
+ int lb_gain;
+ int phy_lna;
u16 data = 0;
+ u16 extlna;
if (!phy->gmode) {
data = 0;
goto writereg;
}
- if (has_loopback_gain(phy)) {
+ phy_lna = (phy->rev < 7) || !(sprom->boardflags_lo & B43_BFL_EXTLNA);
+
+ lb_gain = has_loopback_gain(phy);
+ if (lb_gain) {
int max_lb_gain = phy->max_lb_gain;
- u16 extlna;
u16 i;
if (phy->radio_rev == 8)
max_lb_gain += 0x3E;
else
max_lb_gain += 0x26;
+
if (max_lb_gain >= 0x46) {
extlna = 0x3000;
max_lb_gain -= 0x46;
@@ -3365,101 +3371,54 @@ static void radio2050_rfover_val(struct b43_wldev *dev,
break;
}
- if ((phy->rev < 7) ||
- !(sprom->boardflags_lo & B43_BFL_EXTLNA)) {
- if (phy_register == B43_PHY_RFOVER) {
- data = 0x1B3;
+ if (!phy_lna && extlna)
+ extlna |= 0x8000;
+ extlna |= (i << 8);
+ }
+
+ if (phy_register == B43_PHY_RFOVER) {
+ if (phy_lna)
+ data = 0x01B3;
+ else
+ data = 0x09B3;
+ goto writereg;
+ } else if (phy_register == B43_PHY_RFOVERVAL) {
+ if (lb_gain) {
+ switch (lpd) {
+ case LPD(0, 1, 1):
+ data = (phy_lna ? 0x0F92 : 0x8F92);
goto writereg;
- } else if (phy_register == B43_PHY_RFOVERVAL) {
- extlna |= (i << 8);
- switch (lpd) {
- case LPD(0, 1, 1):
- data = 0x0F92;
- goto writereg;
- case LPD(0, 0, 1):
- case LPD(1, 0, 1):
- data = (0x0092 | extlna);
- goto writereg;
- case LPD(1, 0, 0):
- data = (0x0093 | extlna);
- goto writereg;
- }
- B43_WARN_ON(1);
- }
- B43_WARN_ON(1);
- } else {
- if (phy_register == B43_PHY_RFOVER) {
- data = 0x9B3;
+ case LPD(0, 0, 1):
+ data = (phy_lna ? 0x0092 : 0x8092) | extlna;
goto writereg;
- } else if (phy_register == B43_PHY_RFOVERVAL) {
- if (extlna)
- extlna |= 0x8000;
- extlna |= (i << 8);
- switch (lpd) {
- case LPD(0, 1, 1):
- data = 0x8F92;
- goto writereg;
- case LPD(0, 0, 1):
- data = (0x8092 | extlna);
- goto writereg;
- case LPD(1, 0, 1):
- data = (0x2092 | extlna);
- goto writereg;
- case LPD(1, 0, 0):
- data = (0x2093 | extlna);
- goto writereg;
- }
- B43_WARN_ON(1);
- }
- B43_WARN_ON(1);
- }
- } else {
- if ((phy->rev < 7) ||
- !(sprom->boardflags_lo & B43_BFL_EXTLNA)) {
- if (phy_register == B43_PHY_RFOVER) {
- data = 0x1B3;
+ case LPD(1, 0, 1):
+ data = (phy_lna ? 0x0092 : 0x2092) | extlna;
+ goto writereg;
+ case LPD(1, 0, 0):
+ data = (phy_lna ? 0x0093 : 0x2093) | extlna;
goto writereg;
- } else if (phy_register == B43_PHY_RFOVERVAL) {
- switch (lpd) {
- case LPD(0, 1, 1):
- data = 0x0FB2;
- goto writereg;
- case LPD(0, 0, 1):
- data = 0x00B2;
- goto writereg;
- case LPD(1, 0, 1):
- data = 0x30B2;
- goto writereg;
- case LPD(1, 0, 0):
- data = 0x30B3;
- goto writereg;
- }
- B43_WARN_ON(1);
}
B43_WARN_ON(1);
} else {
- if (phy_register == B43_PHY_RFOVER) {
- data = 0x9B3;
+ switch (lpd) {
+ case LPD(0, 1, 1):
+ data = phy_lna ? 0x0FB2 : 0x8FB2;
+ goto writereg;
+ case LPD(0, 0, 1):
+ data = phy_lna ? 0x00B2 : 0x80B2;
+ goto writereg;
+ case LPD(1, 0, 1):
+ data = phy_lna ? 0x30B2 : 0x20B2;
+ goto writereg;
+ case LPD(1, 0, 0):
+ data = phy_lna ? 0x30B3 : 0x20B3;
goto writereg;
- } else if (phy_register == B43_PHY_RFOVERVAL) {
- switch (lpd) {
- case LPD(0, 1, 1):
- data = 0x8FB2;
- goto writereg;
- case LPD(0, 0, 1):
- data = 0x80B2;
- goto writereg;
- case LPD(1, 0, 1):
- data = 0x20B2;
- goto writereg;
- case LPD(1, 0, 0):
- data = 0x20B3;
- goto writereg;
- }
- B43_WARN_ON(1);
}
B43_WARN_ON(1);
}
+ } else {
+ /* B43_PHY_RFOVER, B43_PHY_RFOVERVAL are the only valid args */
+ B43_WARN_ON(1);
}
writereg:
--
1.5.4.4.684.g0e08
reply other threads:[~2008-03-18 0:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1205801250.2329.53.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.