linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/9] staging/rtl8187se: Remove code without effect
@ 2013-02-13  2:58 Peter Huewe
  2013-02-13  2:58 ` [PATCH 2/9] " Peter Huewe
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  2:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

Local variable AcmCtrl is never read/used after assignment so we can remove
all assignments to it and the related code around the assignments.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   49 +------------------------------
 1 files changed, 1 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index f1db9e4..41419f0 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -964,54 +964,7 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 					break;
 				}
 
-				/* Cehck ACM bit. */
-				/* If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13.	*/
-				{
-					PACI_AIFSN	pAciAifsn = (PACI_AIFSN)(&pAcParam->f.AciAifsn);
-					AC_CODING	eACI = pAciAifsn->f.ACI;
-
-					/*for 8187B AsynIORead issue */
-					u8	AcmCtrl = 0;
-					if (pAciAifsn->f.ACM) {
-						/* ACM bit is 1. */
-						switch (eACI) {
-						case AC0_BE:
-							AcmCtrl |= (BEQ_ACM_EN|BEQ_ACM_CTL|ACM_HW_EN); /* or 0x21 */
-							break;
-
-						case AC2_VI:
-							AcmCtrl |= (VIQ_ACM_EN|VIQ_ACM_CTL|ACM_HW_EN); /* or 0x42 */
-							break;
-
-						case AC3_VO:
-							AcmCtrl |= (VOQ_ACM_EN|VOQ_ACM_CTL|ACM_HW_EN); /* or 0x84 */
-							break;
-
-						default:
-							DMESGW("SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI);
-							break;
-						}
-					} else {
-						/* ACM bit is 0. */
-						switch (eACI) {
-						case AC0_BE:
-							AcmCtrl &= ((~BEQ_ACM_EN) & (~BEQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xDE */
-							break;
-
-						case AC2_VI:
-							AcmCtrl &= ((~VIQ_ACM_EN) & (~VIQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xBD */
-							break;
-
-						case AC3_VO:
-							AcmCtrl &= ((~VOQ_ACM_EN) & (~VOQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0x7B */
-							break;
-
-						default:
-							break;
-						}
-					}
-					write_nic_byte(dev, ACM_CONTROL, 0);
-				}
+				write_nic_byte(dev, ACM_CONTROL, 0);
 			}
 		}
 	}
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/9] staging/rtl8187se: Remove code without effect
  2013-02-13  2:58 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
@ 2013-02-13  2:58 ` Peter Huewe
  2013-02-13  2:58 ` [PATCH 3/9] " Peter Huewe
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  2:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

The local variable u4bAcParam is never read/used after assignment,
thus we can remove the declaration, assignment and any related code.

-> the local variables u1bAIFS, eACI and pAcParam can also be removed.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   39 +------------------------------
 1 files changed, 1 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 41419f0..5495d1e 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -928,44 +928,7 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 
 		for (eACI = 0; eACI < AC_MAX; eACI++) {
 			AcParam.f.AciAifsn.f.ACI = (u8)eACI;
-			{
-				PAC_PARAM	pAcParam = (PAC_PARAM)(&AcParam);
-				AC_CODING	eACI;
-				u8		u1bAIFS;
-				u32		u4bAcParam;
-
-				/*  Retrieve parameters to update. */
-				eACI = pAcParam->f.AciAifsn.f.ACI;
-				u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * ChnlAccessSetting->SlotTimeTimer + aSifsTime;
-				u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET)	|
-						(((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET)	|
-						(((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET)	|
-						(((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
-
-				switch (eACI) {
-				case AC1_BK:
-					/* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */
-					break;
-
-				case AC0_BE:
-					/* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */
-					break;
-
-				case AC2_VI:
-					/* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */
-					break;
-
-				case AC3_VO:
-					/* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */
-					break;
-
-				default:
-					DMESGW("SetHwReg8185(): invalid ACI: %d !\n", eACI);
-					break;
-				}
-
-				write_nic_byte(dev, ACM_CONTROL, 0);
-			}
+			write_nic_byte(dev, ACM_CONTROL, 0);
 		}
 	}
 }
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/9] staging/rtl8187se: Remove code without effect
  2013-02-13  2:58 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
  2013-02-13  2:58 ` [PATCH 2/9] " Peter Huewe
@ 2013-02-13  2:58 ` Peter Huewe
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  2:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

The local variable AcParam is only assigned to but not read/used
afterwards, thus it and all related code can be removed.

The bFollowLegacySetting variable and check can also be removed as it is
always true.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   35 +-----------------------------
 1 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 5495d1e..4aca954 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -869,8 +869,6 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 	struct		r8180_priv *priv = ieee80211_priv(dev);
 	struct		ieee80211_device *ieee = priv->ieee80211;
 	AC_CODING	eACI;
-	AC_PARAM	AcParam;
-	u8		bFollowLegacySetting = 0;
 	u8		u1bAIFS;
 
 	/*
@@ -899,37 +897,8 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 
 	write_nic_byte(dev, AckTimeOutReg, 0x5B); /* <RJ_EXPR_QOS> Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. */
 
-	{ /* Legacy 802.11. */
-		bFollowLegacySetting = 1;
-
-	}
-
-	/* this setting is copied from rtl8187B.  xiong-2006-11-13 */
-	if (bFollowLegacySetting) {
-
-		/*
-		 *	Follow 802.11 seeting to AC parameter, all AC shall use the same parameter.
-		 *	2005.12.01, by rcnjko.
-		 */
-		AcParam.longData = 0;
-		AcParam.f.AciAifsn.f.AIFSN = 2; /* Follow 802.11 DIFS.	*/
-		AcParam.f.AciAifsn.f.ACM = 0;
-		AcParam.f.Ecw.f.ECWmin = ChnlAccessSetting->CWminIndex; /* Follow 802.11 CWmin. */
-		AcParam.f.Ecw.f.ECWmax = ChnlAccessSetting->CWmaxIndex; /* Follow 802.11 CWmax. */
-		AcParam.f.TXOPLimit = 0;
-
-		/* lzm reserved 080826 */
-		/* For turbo mode setting. port from 87B by Isaiah 2008-08-01 */
-		if (ieee->current_network.Turbo_Enable == 1)
-			AcParam.f.TXOPLimit = 0x01FF;
-		/* For 87SE with Intel 4965  Ad-Hoc mode have poor throughput (19MB) */
-		if (ieee->iw_mode == IW_MODE_ADHOC)
-			AcParam.f.TXOPLimit = 0x0020;
-
-		for (eACI = 0; eACI < AC_MAX; eACI++) {
-			AcParam.f.AciAifsn.f.ACI = (u8)eACI;
-			write_nic_byte(dev, ACM_CONTROL, 0);
-		}
+	for (eACI = 0; eACI < AC_MAX; eACI++) {
+		write_nic_byte(dev, ACM_CONTROL, 0);
 	}
 }
 
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary  variables
  2013-02-13  2:58 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
  2013-02-13  2:58 ` [PATCH 2/9] " Peter Huewe
  2013-02-13  2:58 ` [PATCH 3/9] " Peter Huewe
@ 2013-02-13  2:58 ` Peter Huewe
  2013-02-13  3:05   ` [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code Peter Huewe
                     ` (4 more replies)
  2 siblings, 5 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  2:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

The local variables priv and ieee are not used and thus can be removed.
The local variable u1bAIFS is not used/read after assignment and thus
can be removed.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 4aca954..1e54ead 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -866,10 +866,7 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 				   WIRELESS_MODE WirelessMode,
 				   PCHANNEL_ACCESS_SETTING ChnlAccessSetting)
 {
-	struct		r8180_priv *priv = ieee80211_priv(dev);
-	struct		ieee80211_device *ieee = priv->ieee80211;
 	AC_CODING	eACI;
-	u8		u1bAIFS;
 
 	/*
 	 *	<RJ_TODO_8185B>
@@ -891,8 +888,6 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 	write_nic_byte(dev, SIFS, ChnlAccessSetting->SIFS_Timer);
 	write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); /* Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. */
 
-	u1bAIFS = aSifsTime + (2 * ChnlAccessSetting->SlotTimeTimer);
-
 	write_nic_byte(dev, EIFS, ChnlAccessSetting->EIFS_Timer);
 
 	write_nic_byte(dev, AckTimeOutReg, 0x5B); /* <RJ_EXPR_QOS> Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. */
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
@ 2013-02-13  3:05   ` Peter Huewe
  2013-02-13  3:05   ` [PATCH 6/9] staging/rtl8187se: Remove temporary variable for return value Peter Huewe
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  3:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

WriteBBPortUchar reimplements ReadBBPortUchar in its body, so we can
remove the duplicated code by calling ReadBBPortUchar directly.

Unfortunately we have to move ReadBBPortUchar around; while at it we can
also get rid of the temporary variable for the return value.

Also we can remove the local variables UCharData and RegisterContent in
WriteBBPortUchar as they are not used / without effect.

Both functions are only 'local' so we can mark them as static.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 1e54ead..a3b836c 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -287,35 +287,19 @@ u16 RF_ReadReg(struct net_device *dev, u8 offset)
 	return reg;
 }
 
+static u8 ReadBBPortUchar(struct net_device *dev, u32 addr)
+{
+	PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f);
+	return PlatformIORead1Byte(dev, PhyDataR);
+}
 
 /* by Owen on 04/07/14 for writing BB register successfully */
-void WriteBBPortUchar(struct net_device *dev, u32 Data)
+static void WriteBBPortUchar(struct net_device *dev, u32 Data)
 {
-	/* u8	TimeoutCounter; */
-	u8	RegisterContent;
-	u8	UCharData;
-
-	UCharData = (u8)((Data & 0x0000ff00) >> 8);
 	PlatformIOWrite4Byte(dev, PhyAddr, Data);
-	/* for(TimeoutCounter = 10; TimeoutCounter > 0; TimeoutCounter--) */
-	{
-		PlatformIOWrite4Byte(dev, PhyAddr, Data & 0xffffff7f);
-		RegisterContent = PlatformIORead1Byte(dev, PhyDataR);
-		/*if(UCharData == RegisterContent)	*/
-		/*	break;	*/
-	}
+	ReadBBPortUchar(dev, Data);
 }
 
-u8 ReadBBPortUchar(struct net_device *dev, u32 addr)
-{
-	/*u8	TimeoutCounter; */
-	u8	RegisterContent;
-
-	PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f);
-	RegisterContent = PlatformIORead1Byte(dev, PhyDataR);
-
-	return RegisterContent;
-}
 /*
  *	Description:
  *	Perform Antenna settings with antenna diversity on 87SE.
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/9] staging/rtl8187se: Remove temporary variable for return value
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
  2013-02-13  3:05   ` [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code Peter Huewe
@ 2013-02-13  3:05   ` Peter Huewe
  2013-02-13  3:05   ` [PATCH 7/9] staging/rtl8187se: Remove unused functions PlatformIORead2Byte / PlatformIORead4Byte Peter Huewe
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  3:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

The simple PlatformIORead1Byte function doesn't need to store its return
value in a temporary variable; rather simply return the value directly.

By moving the function to the top we can also get rid of the forward
declaration.

The wrapper functions could be easily replaced by direct calls to
read_nic_byte but is kept for readability.

Since this functions is local only we can mark it as static.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index a3b836c..1dfa78e 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -115,6 +115,11 @@ static u8 OFDM_CONFIG[]	= {
 	 *---------------------------------------------------------------
 	 */
 
+static u8 PlatformIORead1Byte(struct net_device *dev, u32 offset)
+{
+	return read_nic_byte(dev, offset);
+}
+
 void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data)
 {
 	write_nic_byte(dev, offset, data);
@@ -127,8 +132,6 @@ void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data)
 	read_nic_word(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
 }
 
-u8 PlatformIORead1Byte(struct net_device *dev, u32 offset);
-
 void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
 {
 	if (offset == PhyAddr) {
@@ -172,16 +175,6 @@ void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
 	}
 }
 
-u8 PlatformIORead1Byte(struct net_device *dev, u32 offset)
-{
-	u8	data = 0;
-
-	data = read_nic_byte(dev, offset);
-
-
-	return data;
-}
-
 u16 PlatformIORead2Byte(struct net_device *dev, u32 offset)
 {
 	u16	data = 0;
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/9] staging/rtl8187se: Remove unused functions PlatformIORead2Byte / PlatformIORead4Byte
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
  2013-02-13  3:05   ` [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code Peter Huewe
  2013-02-13  3:05   ` [PATCH 6/9] staging/rtl8187se: Remove temporary variable for return value Peter Huewe
@ 2013-02-13  3:05   ` Peter Huewe
  2013-02-13  3:05   ` [PATCH 8/9] staging/rtl8187se: Remove duplicated code by using an offset Peter Huewe
  2013-02-13  3:05   ` [PATCH 9/9] staging/rtl8187se: Mark functions as static to silence sparse Peter Huewe
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  3:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

These two functions PlatformIORead2Byte and PlatformIORead4Byte are
unused and thus can be removed.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 1dfa78e..005fb0b 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -175,26 +175,6 @@ void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
 	}
 }
 
-u16 PlatformIORead2Byte(struct net_device *dev, u32 offset)
-{
-	u16	data = 0;
-
-	data = read_nic_word(dev, offset);
-
-
-	return data;
-}
-
-u32 PlatformIORead4Byte(struct net_device *dev, u32 offset)
-{
-	u32	data = 0;
-
-	data = read_nic_dword(dev, offset);
-
-
-	return data;
-}
-
 void SetOutputEnableOfRfPins(struct net_device *dev)
 {
 	write_nic_word(dev, RFPinsEnable, 0x1bff);
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/9] staging/rtl8187se: Remove duplicated code by using an offset
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
                     ` (2 preceding siblings ...)
  2013-02-13  3:05   ` [PATCH 7/9] staging/rtl8187se: Remove unused functions PlatformIORead2Byte / PlatformIORead4Byte Peter Huewe
@ 2013-02-13  3:05   ` Peter Huewe
  2013-02-13  3:05   ` [PATCH 9/9] staging/rtl8187se: Mark functions as static to silence sparse Peter Huewe
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  3:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

In SetAntennaConfig87SE both branches of if (bAntDiversity) do exactly
the same, except that there is an offset of 0x80 for the register values
if bAntDiversity is true.

-> Consolidate both branches and assign the offset if necessary.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   76 +++++++++++--------------------
 1 files changed, 26 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 005fb0b..2ca857d 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -284,62 +284,38 @@ bool SetAntennaConfig87SE(struct net_device *dev,
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	bool   bAntennaSwitched = true;
+	u8	ant_diversity_offset = 0x00; /* 0x00 = disabled, 0x80 = enabled */
 
 	/* printk("SetAntennaConfig87SE(): DefaultAnt(%d), bAntDiversity(%d)\n", DefaultAnt, bAntDiversity); */
 
 	/* Threshold for antenna diversity. */
 	write_phy_cck(dev, 0x0c, 0x09); /* Reg0c : 09 */
 
-	if (bAntDiversity) {	/*	Enable Antenna Diversity. */
-		if (DefaultAnt == 1) {	/* aux antenna */
-
-			/* Mac register, aux antenna */
-			write_nic_byte(dev, ANTSEL, 0x00);
-
-			/* Config CCK RX antenna. */
-			write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
-			write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
-
-			/* Config OFDM RX antenna. */
-			write_phy_ofdm(dev, 0x0D, 0x54);	/* Reg0d : 54 */
-			write_phy_ofdm(dev, 0x18, 0xb2);	/* Reg18 : b2 */
-		} else { /*  use main antenna */
-			/* Mac register, main antenna */
-			write_nic_byte(dev, ANTSEL, 0x03);
-			/* base band */
-			/*  Config CCK RX antenna. */
-			write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
-			write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
-
-			/* Config OFDM RX antenna. */
-			write_phy_ofdm(dev, 0x0d, 0x5c);  /* Reg0d : 5c	*/
-			write_phy_ofdm(dev, 0x18, 0xb2);  /* Reg18 : b2	*/
-		}
-	} else {
-		/* Disable Antenna Diversity. */
-		if (DefaultAnt == 1) { /* aux Antenna */
-			/* Mac register, aux antenna */
-			write_nic_byte(dev, ANTSEL, 0x00);
-
-			/* Config CCK RX antenna. */
-			write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
-			write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
-
-			/* Config OFDM RX antenna. */
-			write_phy_ofdm(dev, 0x0D, 0x54);	/* Reg0d : 54 */
-			write_phy_ofdm(dev, 0x18, 0x32);	/* Reg18 : 32 */
-		} else { /* main Antenna */
-			/* Mac register, main antenna */
-			write_nic_byte(dev, ANTSEL, 0x03);
-
-			/* Config CCK RX antenna.	*/
-			write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
-			write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
-
-			/* Config OFDM RX antenna. */
-			write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
-			write_phy_ofdm(dev, 0x18, 0x32); /*Reg18 : 32 */
-		}
+	if (bAntDiversity)	/*	Enable Antenna Diversity. */
+		ant_diversity_offset = 0x80;
+
+	if (DefaultAnt == 1) { /* aux Antenna */
+		/* Mac register, aux antenna */
+		write_nic_byte(dev, ANTSEL, 0x00);
+
+		/* Config CCK RX antenna. */
+		write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
+		write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 | ant_diversity_offset */
+
+		/* Config OFDM RX antenna. */
+		write_phy_ofdm(dev, 0x0D, 0x54);	/* Reg0d : 54 */
+		write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset);	/* Reg18 : 32 */
+	} else { /* main Antenna */
+		/* Mac register, main antenna */
+		write_nic_byte(dev, ANTSEL, 0x03);
+
+		/* Config CCK RX antenna.	*/
+		write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
+		write_phy_cck(dev, 0x01, 0x47|ant_diversity_offset); /* Reg01 : 47 */
+
+		/* Config OFDM RX antenna. */
+		write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
+		write_phy_ofdm(dev, 0x18, 0x32|ant_diversity_offset); /*Reg18 : 32 */
 	}
 	priv->CurrAntennaIndex = DefaultAnt; /* Update default settings. */
 	return	bAntennaSwitched;
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 9/9] staging/rtl8187se: Mark functions as static to silence sparse
  2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
                     ` (3 preceding siblings ...)
  2013-02-13  3:05   ` [PATCH 8/9] staging/rtl8187se: Remove duplicated code by using an offset Peter Huewe
@ 2013-02-13  3:05   ` Peter Huewe
  4 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  3:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Peter Huewe, Andrew Miller, Maxim Mikityanskiy, YAMANE Toshiaki,
	devel, linux-kernel

Sparse complains that some functions can be declared as static:
123:6: warning: symbol 'PlatformIOWrite1Byte' was not declared. Should it be static?
129:6: warning: symbol 'PlatformIOWrite2Byte' was not declared. Should it be static?
135:6: warning: symbol 'PlatformIOWrite4Byte' was not declared. Should it be static?
178:6: warning: symbol 'SetOutputEnableOfRfPins' was not declared.  Should it be static?
354:6: warning: symbol 'ZEBRA_Config_85BASIC_HardCode' was not declared.  Should it be static?
655:6: warning: symbol 'InitTxPwrTracking87SE' was not declared. Should it be static?
665:6: warning: symbol 'PhyConfig8185' was not declared. Should it be static?
692:6: warning: symbol 'HwConfigureRTL8185' was not declared. Should it be static?
817:4: warning: symbol 'GetSupportedWirelessMode8185' was not declared.  Should it be static?
822:6: warning: symbol 'ActUpdateChannelAccessSetting' was not declared.  Should it be static?
857:6: warning: symbol 'ActSetWirelessMode8185' was not declared. Should it be static?
914:6: warning: symbol 'MgntDisconnectIBSS' was not declared. Should it be static?
940:6: warning: symbol 'MlmeDisassociateRequest' was not declared.  Should it be static?
957:6: warning: symbol 'MgntDisconnectAP' was not declared. Should it be static?
975:6: warning: symbol 'MgntDisconnect' was not declared. Should it be static?
1011:6: warning: symbol 'SetRFPowerState' was not declared. Should it be static?
1115:6: warning: symbol 'InactivePowerSave' was not declared. Should it be static?

-> Add the static keyword.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   34 +++++++++++++++---------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 2ca857d..978dc5f 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -120,19 +120,19 @@ static u8 PlatformIORead1Byte(struct net_device *dev, u32 offset)
 	return read_nic_byte(dev, offset);
 }
 
-void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data)
+static void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data)
 {
 	write_nic_byte(dev, offset, data);
 	read_nic_byte(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
 }
 
-void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data)
+static void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data)
 {
 	write_nic_word(dev, offset, data);
 	read_nic_word(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
 }
 
-void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
+static void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
 {
 	if (offset == PhyAddr) {
 	/* For Base Band configuration. */
@@ -175,7 +175,7 @@ void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
 	}
 }
 
-void SetOutputEnableOfRfPins(struct net_device *dev)
+static void SetOutputEnableOfRfPins(struct net_device *dev)
 {
 	write_nic_word(dev, RFPinsEnable, 0x1bff);
 }
@@ -327,7 +327,7 @@ bool SetAntennaConfig87SE(struct net_device *dev,
  *--------------------------------------------------------------
  */
 
-void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev)
+static void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev)
 {
 
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -628,7 +628,7 @@ void UpdateInitialGain(struct net_device *dev)
  *		Tx Power tracking mechanism routine on 87SE.
  *	Created by Roger, 2007.12.11.
  */
-void InitTxPwrTracking87SE(struct net_device *dev)
+static void InitTxPwrTracking87SE(struct net_device *dev)
 {
 	u32	u4bRfReg;
 
@@ -638,7 +638,7 @@ void InitTxPwrTracking87SE(struct net_device *dev)
 	RF_WriteReg(dev, 0x02, u4bRfReg|PWR_METER_EN);			mdelay(1);
 }
 
-void PhyConfig8185(struct net_device *dev)
+static void PhyConfig8185(struct net_device *dev)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 		write_nic_dword(dev, RCR, priv->ReceiveConfig);
@@ -665,7 +665,7 @@ void PhyConfig8185(struct net_device *dev)
 	return;
 }
 
-void HwConfigureRTL8185(struct net_device *dev)
+static void HwConfigureRTL8185(struct net_device *dev)
 {
 	/* RTL8185_TODO: Determine Retrylimit, TxAGC, AutoRateFallback control. */
 	u8 bUNIVERSAL_CONTROL_RL = 0;
@@ -790,12 +790,12 @@ static void MacConfig_85BASIC(struct net_device *dev)
 	write_nic_byte(dev, 0x24E, 0x01);
 }
 
-u8 GetSupportedWirelessMode8185(struct net_device *dev)
+static u8 GetSupportedWirelessMode8185(struct net_device *dev)
 {
 	return WIRELESS_MODE_B | WIRELESS_MODE_G;
 }
 
-void ActUpdateChannelAccessSetting(struct net_device *dev,
+static void ActUpdateChannelAccessSetting(struct net_device *dev,
 				   WIRELESS_MODE WirelessMode,
 				   PCHANNEL_ACCESS_SETTING ChnlAccessSetting)
 {
@@ -830,7 +830,7 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
 	}
 }
 
-void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode)
+static void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode)
 {
 	struct  r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	struct  ieee80211_device *ieee = priv->ieee80211;
@@ -887,7 +887,7 @@ void rtl8185b_irq_enable(struct net_device *dev)
 	write_nic_dword(dev, IMR, priv->IntrMask);
 }
 
-void MgntDisconnectIBSS(struct net_device *dev)
+static void MgntDisconnectIBSS(struct net_device *dev)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	u8 i;
@@ -913,7 +913,7 @@ void MgntDisconnectIBSS(struct net_device *dev)
 	notify_wx_assoc_event(priv->ieee80211);
 }
 
-void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn)
+static void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	u8 i;
@@ -930,7 +930,7 @@ void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn)
 	}
 }
 
-void MgntDisconnectAP(struct net_device *dev, u8 asRsn)
+static void MgntDisconnectAP(struct net_device *dev, u8 asRsn)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 
@@ -948,7 +948,7 @@ void MgntDisconnectAP(struct net_device *dev, u8 asRsn)
 	priv->ieee80211->state = IEEE80211_NOLINK;
 }
 
-bool MgntDisconnect(struct net_device *dev, u8 asRsn)
+static bool MgntDisconnect(struct net_device *dev, u8 asRsn)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	/*
@@ -984,7 +984,7 @@ bool MgntDisconnect(struct net_device *dev, u8 asRsn)
  *	Assumption:
  *		PASSIVE LEVEL.
  */
-bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState)
+static bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState)
 {
 	struct	r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	bool	bResult = false;
@@ -1088,7 +1088,7 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u
 	return bActionAllowed;
 }
 
-void InactivePowerSave(struct net_device *dev)
+static void InactivePowerSave(struct net_device *dev)
 {
 	struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
 	/*
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code
  2013-02-13  2:54 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
@ 2013-02-13  2:54 ` Peter Huewe
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Huewe @ 2013-02-13  2:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Yunhong Jiang, Sheng Yang, Mike A. Chan, Xiaohui Xin, devel,
	linux-kernel, Peter Huewe

WriteBBPortUchar reimplements ReadBBPortUchar in its body, so we can
remove the duplicated code by calling ReadBBPortUchar directly.

Unfortunately we have to move ReadBBPortUchar around; while at it we can
also get rid of the temporary variable for the return value.

Also we can remove the local variables UCharData and RegisterContent in
WriteBBPortUchar as they are not used / without effect.

Both functions are only 'local' so we can mark them as static.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/rtl8187se/r8185b_init.c |   30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 1e54ead..a3b836c 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -287,35 +287,19 @@ u16 RF_ReadReg(struct net_device *dev, u8 offset)
 	return reg;
 }
 
+static u8 ReadBBPortUchar(struct net_device *dev, u32 addr)
+{
+	PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f);
+	return PlatformIORead1Byte(dev, PhyDataR);
+}
 
 /* by Owen on 04/07/14 for writing BB register successfully */
-void WriteBBPortUchar(struct net_device *dev, u32 Data)
+static void WriteBBPortUchar(struct net_device *dev, u32 Data)
 {
-	/* u8	TimeoutCounter; */
-	u8	RegisterContent;
-	u8	UCharData;
-
-	UCharData = (u8)((Data & 0x0000ff00) >> 8);
 	PlatformIOWrite4Byte(dev, PhyAddr, Data);
-	/* for(TimeoutCounter = 10; TimeoutCounter > 0; TimeoutCounter--) */
-	{
-		PlatformIOWrite4Byte(dev, PhyAddr, Data & 0xffffff7f);
-		RegisterContent = PlatformIORead1Byte(dev, PhyDataR);
-		/*if(UCharData == RegisterContent)	*/
-		/*	break;	*/
-	}
+	ReadBBPortUchar(dev, Data);
 }
 
-u8 ReadBBPortUchar(struct net_device *dev, u32 addr)
-{
-	/*u8	TimeoutCounter; */
-	u8	RegisterContent;
-
-	PlatformIOWrite4Byte(dev, PhyAddr, addr & 0xffffff7f);
-	RegisterContent = PlatformIORead1Byte(dev, PhyDataR);
-
-	return RegisterContent;
-}
 /*
  *	Description:
  *	Perform Antenna settings with antenna diversity on 87SE.
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-02-13  3:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13  2:58 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
2013-02-13  2:58 ` [PATCH 2/9] " Peter Huewe
2013-02-13  2:58 ` [PATCH 3/9] " Peter Huewe
2013-02-13  2:58 ` [PATCH 4/9] staging/rtl8187se: Remove unused/unnecessary variables Peter Huewe
2013-02-13  3:05   ` [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code Peter Huewe
2013-02-13  3:05   ` [PATCH 6/9] staging/rtl8187se: Remove temporary variable for return value Peter Huewe
2013-02-13  3:05   ` [PATCH 7/9] staging/rtl8187se: Remove unused functions PlatformIORead2Byte / PlatformIORead4Byte Peter Huewe
2013-02-13  3:05   ` [PATCH 8/9] staging/rtl8187se: Remove duplicated code by using an offset Peter Huewe
2013-02-13  3:05   ` [PATCH 9/9] staging/rtl8187se: Mark functions as static to silence sparse Peter Huewe
  -- strict thread matches above, loose matches on Subject: below --
2013-02-13  2:54 [PATCH 1/9] staging/rtl8187se: Remove code without effect Peter Huewe
2013-02-13  2:54 ` [PATCH 5/9] staging/rtl8187se: Reuse ReadBBPortUchar to avoid duplicated code Peter Huewe

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).