* [RFC] Eliminate some 'G Mode Enable' magic numbers
@ 2007-03-14 16:18 Larry Finger
2007-03-14 19:49 ` John W. Linville
0 siblings, 1 reply; 3+ messages in thread
From: Larry Finger @ 2007-03-14 16:18 UTC (permalink / raw)
To: Larry Finger; +Cc: Bcm43xx-dev, linux-wireless
In code manipulating the TM State Low register of 802.11 cores, two
different magic numbers are used to reference the 'G Mode Enable' bit.
One of these, 0x20000000, is clear, but the other, (0x800 << 18), is not.
This patch replaces both types with a defined constant. In addition, two
bits in the TM State High registers are given definitions to help in
following the code.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx.h
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -277,11 +277,14 @@
#define BCM43xx_SBTMSTATELOW_REJECT 0x02
#define BCM43xx_SBTMSTATELOW_CLOCK 0x10000
#define BCM43xx_SBTMSTATELOW_FORCE_GATE_CLOCK 0x20000
+#define BCM43xx_SBTMSTATELOW_G_MODE_ENABLE 0x20000000
/* sbtmstatehigh state flags */
#define BCM43xx_SBTMSTATEHIGH_SERROR 0x00000001
#define BCM43xx_SBTMSTATEHIGH_BUSY 0x00000004
#define BCM43xx_SBTMSTATEHIGH_TIMEOUT 0x00000020
+#define BCM43xx_SBTMSTATEHIGH_G_PHY_AVAIL 0x00010000
+#define BCM43xx_SBTMSTATEHIGH_A_PHY_AVAIL 0x00020000
#define BCM43xx_SBTMSTATEHIGH_COREFLAGS 0x1FFF0000
#define BCM43xx_SBTMSTATEHIGH_DMA64BIT 0x10000000
#define BCM43xx_SBTMSTATEHIGH_GATEDCLK 0x20000000
Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -168,16 +168,16 @@ int bcm43xx_phy_connect(struct bcm43xx_p
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH);
if (connect) {
- if (!(flags & 0x00010000))
+ if (!(flags & BCM43xx_SBTMSTATEHIGH_G_PHY_AVAIL))
return -ENODEV;
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
- flags |= (0x800 << 18);
+ flags |= BCM43xx_SBTMSTATELOW_G_MODE_ENABLE;
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags);
} else {
- if (!(flags & 0x00020000))
+ if (!(flags & BCM43xx_SBTMSTATEHIGH_A_PHY_AVAIL))
return -ENODEV;
flags = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
- flags &= ~(0x800 << 18);
+ flags &= ~BCM43xx_SBTMSTATELOW_G_MODE_ENABLE;
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, flags);
}
out:
Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_main.c
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -1389,7 +1389,7 @@ void bcm43xx_wireless_core_reset(struct
& ~(BCM43xx_SBF_MAC_ENABLED | 0x00000002));
} else {
if (connect_phy)
- flags |= 0x20000000;
+ flags |= BCM43xx_SBTMSTATELOW_G_MODE_ENABLE;
bcm43xx_phy_connect(bcm, connect_phy);
bcm43xx_core_enable(bcm, flags);
bcm43xx_write16(bcm, 0x03E6, 0x0000);
@@ -3662,7 +3662,7 @@ int bcm43xx_select_wireless_core(struct
u32 sbtmstatelow;
sbtmstatelow = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
- sbtmstatelow |= 0x20000000;
+ sbtmstatelow |= BCM43xx_SBTMSTATELOW_G_MODE_ENABLE;
bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
}
err = wireless_core_up(bcm, 1);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] Eliminate some 'G Mode Enable' magic numbers
2007-03-14 16:18 [RFC] Eliminate some 'G Mode Enable' magic numbers Larry Finger
@ 2007-03-14 19:49 ` John W. Linville
2007-03-14 20:04 ` Larry Finger
0 siblings, 1 reply; 3+ messages in thread
From: John W. Linville @ 2007-03-14 19:49 UTC (permalink / raw)
To: Larry Finger; +Cc: Bcm43xx-dev, linux-wireless
On Wed, Mar 14, 2007 at 11:18:28AM -0500, Larry Finger wrote:
> In code manipulating the TM State Low register of 802.11 cores, two
> different magic numbers are used to reference the 'G Mode Enable' bit.
> One of these, 0x20000000, is clear, but the other, (0x800 << 18), is not.
> This patch replaces both types with a defined constant. In addition, two
> bits in the TM State High registers are given definitions to help in
> following the code.
Looks reasonable to me -- not sure why this is an RFC? Does anyone
object?
John
--
John W. Linville
linville@tuxdriver.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Eliminate some 'G Mode Enable' magic numbers
2007-03-14 19:49 ` John W. Linville
@ 2007-03-14 20:04 ` Larry Finger
0 siblings, 0 replies; 3+ messages in thread
From: Larry Finger @ 2007-03-14 20:04 UTC (permalink / raw)
To: John W. Linville; +Cc: Bcm43xx-dev, linux-wireless
John W. Linville wrote:
> On Wed, Mar 14, 2007 at 11:18:28AM -0500, Larry Finger wrote:
>> In code manipulating the TM State Low register of 802.11 cores, two
>> different magic numbers are used to reference the 'G Mode Enable' bit.
>> One of these, 0x20000000, is clear, but the other, (0x800 << 18), is not.
>> This patch replaces both types with a defined constant. In addition, two
>> bits in the TM State High registers are given definitions to help in
>> following the code.
>
> Looks reasonable to me -- not sure why this is an RFC? Does anyone
> object?
Not so far. I'll make it a proper patch.
Larry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-14 20:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-14 16:18 [RFC] Eliminate some 'G Mode Enable' magic numbers Larry Finger
2007-03-14 19:49 ` John W. Linville
2007-03-14 20:04 ` Larry Finger
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).