Skip to contentSkip to conversation

checkpatch changes and brcmfmac cleanup

PATCH In review Arend van Spriel 4 participants 26 messages Jul 18, 2011 – Jul 19, 2011 Staging

lore
Share & tools
lore
#0 lore raw

cover checkpatch changes and brcmfmac cleanup

This series removes several checkpatch errors and warnings in the drivers and several cleanup changes in brcmfmac driver.

Arend van Spriel (2):
staging: brcm80211: replace simple_strtoul usage in brcmsmac
staging: brcm80211: replace simple_strtoul usage in brcmfmac

Franky Lin (10):
staging: brcm80211: remove private timeout functions in fullmac
staging: brcm80211: move brcmf_mmc_suspend to sdio layer in fullmac
staging: brcm80211: remove global wait queue head
sdioh_spinwait_sleep
staging: brcm80211: remove code for unsupported chip
staging: brcm80211: get rid of sd debug message macro in fullmac
staging: brcm80211: remove structure sdio_hc in brcmfmac
staging: brcm80211: remove SDLX_MSG from brcmfmac
staging: brcm80211: remove BRCMF_SD_* debug macros from brcmfmac
staging: brcm80211: absorb brcmf_sdcard_attach into brcmf_sdio_probe
staging: brcm80211: absorb brcmf_sdcard_detach into brcmf_sdio_remove

Roland Vossen (7):
staging: brcm80211: fix for checkpatch warnings in phy directory
staging: brcm80211: resolved checkpatch warnings in LCN phy
staging: brcm80211: resolved checkpatch warnings in N phy
staging: brcm80211: fixed build issue for big endian platforms
staging: brcm80211: remove MIPS specific 'sync' instruction in
fullmac
staging: brcm80211: removed R_REG and OR_REG macro's from fullmac
staging: brcm80211: removed global variable from sdio fullmac

 drivers/staging/brcm80211/brcmfmac/bcmsdh.c        |  246 +-
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c  |  337 +-
 drivers/staging/brcm80211/brcmfmac/dhd.h           |   49 -
 drivers/staging/brcm80211/brcmfmac/dhd_common.c    |   27 +-
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |   66 -
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |   97 +-
 drivers/staging/brcm80211/brcmfmac/sdio_host.h     |   30 +-
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c   |    8 -
 drivers/staging/brcm80211/brcmsmac/dma.h           |    1 +
 drivers/staging/brcm80211/brcmsmac/main.c          |   16 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c   |  244 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h   |   51 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_int.h   |  138 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c   |  413 ++-
 drivers/staging/brcm80211/brcmsmac/phy/phy_n.c     | 3777 ++++++++++----------
 drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c |  136 +-
 .../staging/brcm80211/brcmsmac/phy/phytbl_lcn.c    | 1168 ++----
 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c  |    3 +-
 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h  |   24 +-
 drivers/staging/brcm80211/brcmsmac/types.h         |    8 +-
 20 files changed, 3195 insertions(+), 3644 deletions(-)
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/19 staging: brcm80211: resolved checkpatch warnings in LCN phy

From: Roland Vossen <[email protected]>

Refactored code to not exceed the 80 char limit.

---
 drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c |   46 ++++++++--------------
 1 files changed, 16 insertions(+), 30 deletions(-)
drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +16 -30
index a109866..3d140eb 100644
@@ -4342,39 +4342,25 @@ static void wlc_lcnphy_tbl_init(struct brcms_phy *pi)
 	}
 
 	if (LCNREV_IS(pi->pubpi.phy_rev, 2)) {
+		const struct phytbl_info *tb;
+		int l;
+
 		if (CHSPEC_IS2G(pi->radio_chanspec)) {
-			for (idx = 0;
-			     idx < dot11lcnphytbl_rx_gain_info_2G_rev2_sz;
-			     idx++)
-				if (pi->sh->boardflags & BFL_EXTLNA)
-					wlc_lcnphy_write_table(
-						pi,
-						&
-						dot11lcnphytbl_rx_gain_info_extlna_2G_rev2
-						[idx]);
-				else
-					wlc_lcnphy_write_table(
-						pi,
-						&
-						dot11lcnphytbl_rx_gain_info_2G_rev2
-						[idx]);
+			l = dot11lcnphytbl_rx_gain_info_2G_rev2_sz;
+			if (pi->sh->boardflags & BFL_EXTLNA)
+				tb = dot11lcnphytbl_rx_gain_info_extlna_2G_rev2;
+			else
+				tb = dot11lcnphytbl_rx_gain_info_2G_rev2;
 		} else {
-			for (idx = 0;
-			     idx < dot11lcnphytbl_rx_gain_info_5G_rev2_sz;
-			     idx++)
-				if (pi->sh->boardflags & BFL_EXTLNA_5GHz)
-					wlc_lcnphy_write_table(
-						pi,
-						&
-						dot11lcnphytbl_rx_gain_info_extlna_5G_rev2
-						[idx]);
-				else
-					wlc_lcnphy_write_table(
-						pi,
-						&
-						dot11lcnphytbl_rx_gain_info_5G_rev2
-						[idx]);
+			l = dot11lcnphytbl_rx_gain_info_5G_rev2_sz;
+			if (pi->sh->boardflags & BFL_EXTLNA_5GHz)
+				tb = dot11lcnphytbl_rx_gain_info_extlna_5G_rev2;
+			else
+				tb = dot11lcnphytbl_rx_gain_info_5G_rev2;
 		}
+
+		for (idx = 0; idx < l; idx++)
+			wlc_lcnphy_write_table(pi, &tb[idx]);
 	}
 
 	if ((pi->sh->boardflags & BFL_FEM)
Signature · 1 line
1.7.4.1
#3 lore raw

PATCH 3/19 staging: brcm80211: resolved checkpatch warnings in N phy

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

Code that exceeded the 80 char limit has been placed in separate functions. Checkpatch warnings for the phy dir are now reduced to 1.

---
 drivers/staging/brcm80211/brcmsmac/phy/phy_n.c |  304 ++++++++++--------------
 1 files changed, 128 insertions(+), 176 deletions(-)
drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +128 -176
index ca6f749..fb64597 100644
@@ -14544,6 +14544,44 @@ static void wlc_phy_txpwrctrl_config_nphy(struct brcms_phy *pi)
 		pi->phy_5g_pwrgain = true;
 }
 
+static s32 get_rf_pwr_offset(struct brcms_phy *pi, s16 pga_gn, s16 pad_gn)
+{
+	s32 rfpwr_offset = 0;
+
+	if (CHSPEC_IS2G(pi->radio_chanspec)) {
+		if ((pi->pubpi.radiorev == 3) ||
+		    (pi->pubpi.radiorev == 4) ||
+		    (pi->pubpi.radiorev == 6))
+			rfpwr_offset = (s16)
+				       nphy_papd_padgain_dlt_2g_2057rev3n4
+				       [pad_gn];
+		else if (pi->pubpi.radiorev == 5)
+			rfpwr_offset = (s16)
+				       nphy_papd_padgain_dlt_2g_2057rev5
+				       [pad_gn];
+		else if ((pi->pubpi.radiorev == 7)
+			 || (pi->pubpi.radiorev ==
+			     8))
+			rfpwr_offset = (s16)
+				       nphy_papd_padgain_dlt_2g_2057rev7
+				       [pad_gn];
+	} else {
+		if ((pi->pubpi.radiorev == 3) ||
+		    (pi->pubpi.radiorev == 4) ||
+		    (pi->pubpi.radiorev == 6))
+			rfpwr_offset = (s16)
+				       nphy_papd_pgagain_dlt_5g_2057
+				       [pga_gn];
+		else if ((pi->pubpi.radiorev == 7)
+			 || (pi->pubpi.radiorev ==
+			     8))
+			rfpwr_offset = (s16)
+				       nphy_papd_pgagain_dlt_5g_2057rev7
+				       [pga_gn];
+	}
+	return rfpwr_offset;
+}
+
 void wlc_phy_init_nphy(struct brcms_phy *pi)
 {
 	u16 val;
@@ -14714,7 +14752,7 @@ void wlc_phy_init_nphy(struct brcms_phy *pi)
 		u16 idx;
 		s16 pga_gn = 0;
 		s16 pad_gn = 0;
-		s32 rfpwr_offset = 0;
+		s32 rfpwr_offset;
 
 		if (PHY_IPA(pi)) {
 			tx_pwrctrl_tbl = wlc_phy_get_ipa_gaintbl_nphy(pi);
@@ -14764,38 +14802,8 @@ void wlc_phy_init_nphy(struct brcms_phy *pi)
 			for (idx = 0; idx < 128; idx++) {
 				pga_gn = (tx_pwrctrl_tbl[idx] >> 24) & 0xf;
 				pad_gn = (tx_pwrctrl_tbl[idx] >> 19) & 0x1f;
-
-				if (CHSPEC_IS2G(pi->radio_chanspec)) {
-					if ((pi->pubpi.radiorev == 3) ||
-					    (pi->pubpi.radiorev == 4) ||
-					    (pi->pubpi.radiorev == 6))
-						rfpwr_offset = (s16)
-							       nphy_papd_padgain_dlt_2g_2057rev3n4
-							       [pad_gn];
-					else if (pi->pubpi.radiorev == 5)
-						rfpwr_offset = (s16)
-							       nphy_papd_padgain_dlt_2g_2057rev5
-							       [pad_gn];
-					else if ((pi->pubpi.radiorev == 7)
-						 || (pi->pubpi.radiorev ==
-						     8))
-						rfpwr_offset = (s16)
-							       nphy_papd_padgain_dlt_2g_2057rev7
-							       [pad_gn];
-				} else {
-					if ((pi->pubpi.radiorev == 3) ||
-					    (pi->pubpi.radiorev == 4) ||
-					    (pi->pubpi.radiorev == 6))
-						rfpwr_offset = (s16)
-							       nphy_papd_pgagain_dlt_5g_2057
-							       [pga_gn];
-					else if ((pi->pubpi.radiorev == 7)
-						 || (pi->pubpi.radiorev ==
-						     8))
-						rfpwr_offset = (s16)
-							       nphy_papd_pgagain_dlt_5g_2057rev7
-							       [pga_gn];
-				}
+				rfpwr_offset = get_rf_pwr_offset(pi, pga_gn,
+								 pad_gn);
 				wlc_phy_table_write_nphy(
 					pi,
 					NPHY_TBL_ID_CORE1TXPWRCTL,
@@ -20407,6 +20415,45 @@ wlc_phy_scale_offset_rssi_nphy(struct brcms_phy *pi, u16 scale, s8 offset,
 		write_phy_reg(pi, 0x1bb, valuetostuff);
 }
 
+static void brcms_phy_wr_tx_mux(struct brcms_phy *pi, u8 core)
+{
+	if (PHY_IPA(pi)) {
+		if (NREV_GE(pi->pubpi.phy_rev, 7))
+			write_radio_reg(pi,
+					((core == PHY_CORE_0) ?
+					 RADIO_2057_TX0_TX_SSI_MUX :
+					 RADIO_2057_TX1_TX_SSI_MUX),
+					(CHSPEC_IS5G(pi->radio_chanspec) ?
+					0xc : 0xe));
+		else
+			write_radio_reg(pi,
+					RADIO_2056_TX_TX_SSI_MUX |
+					((core == PHY_CORE_0) ?
+					 RADIO_2056_TX0 : RADIO_2056_TX1),
+					(CHSPEC_IS5G(pi->radio_chanspec) ?
+					0xc : 0xe));
+	} else {
+		if (NREV_GE(pi->pubpi.phy_rev, 7)) {
+			write_radio_reg(pi,
+					((core == PHY_CORE_0) ?
+					 RADIO_2057_TX0_TX_SSI_MUX :
+					 RADIO_2057_TX1_TX_SSI_MUX),
+					0x11);
+
+			if (pi->pubpi.radioid == BCM2057_ID)
+				write_radio_reg(pi,
+						RADIO_2057_IQTEST_SEL_PU, 0x1);
+
+		} else {
+			write_radio_reg(pi,
+					RADIO_2056_TX_TX_SSI_MUX |
+					((core == PHY_CORE_0) ?
+					 RADIO_2056_TX0 : RADIO_2056_TX1),
+					0x11);
+		}
+	}
+}
+
 void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type)
 {
 	u16 mask, val;
@@ -20529,103 +20576,13 @@ void wlc_phy_rssisel_nphy(struct brcms_phy *pi, u8 core_code, u8 rssi_type)
 							    (core ==
 							     PHY_CORE_0) ? 0xa6
 							    : 0xa7, mask, val);
-
-						if (PHY_IPA(pi)) {
-							if (NREV_GE
-								    (pi->pubpi.
-								    phy_rev,
-								    7))
-								write_radio_reg
-									(pi,
-									((core
-									  ==
-									  PHY_CORE_0)
-									 ?
-									 RADIO_2057_TX0_TX_SSI_MUX
-									 :
-									 RADIO_2057_TX1_TX_SSI_MUX),
-									(
-										CHSPEC_IS5G
-										(
-											pi
-											->
-											radio_chanspec)
-										?
-										0xc
-										:
-										0xe));
-							else
-								write_radio_reg
-								(
-									pi,
-									RADIO_2056_TX_TX_SSI_MUX
-									|
-									((core
-									  ==
-									  PHY_CORE_0)
-									 ?
-									 RADIO_2056_TX0
-									 :
-									 RADIO_2056_TX1),
-									(
-										CHSPEC_IS5G
-										(
-											pi
-											->
-											radio_chanspec)
-										?
-										0xc
-										:
-										0xe));
-						} else {
-
-							if (NREV_GE
-								    (pi->pubpi.
-								    phy_rev,
-								    7)) {
-								write_radio_reg
-									(pi,
-									((core
-									  ==
-									  PHY_CORE_0)
-									 ?
-									 RADIO_2057_TX0_TX_SSI_MUX
-									 :
-									 RADIO_2057_TX1_TX_SSI_MUX),
-									0x11);
-
-								if (pi->pubpi.
-								    radioid ==
-								    BCM2057_ID)
-									write_radio_reg
-									(
-										pi,
-										RADIO_2057_IQTEST_SEL_PU,
-										0x1);
-
-							} else {
-								write_radio_reg
-								(
-									pi,
-									RADIO_2056_TX_TX_SSI_MUX
-									|
-									((core
-									  ==
-									  PHY_CORE_0)
-									 ?
-									 RADIO_2056_TX0
-									 :
-									 RADIO_2056_TX1),
-									0x11);
-							}
-						}
-
+						brcms_phy_wr_tx_mux(pi, core);
 						afectrlovr_rssi_val = 1 << 9;
 						mod_phy_reg(pi,
-							    (core ==
-							     PHY_CORE_0) ? 0x8f
-							    : 0xa5, (0x1 << 9),
-							    afectrlovr_rssi_val);
+							   (core ==
+							    PHY_CORE_0) ? 0x8f
+							   : 0xa5, (0x1 << 9),
+							   afectrlovr_rssi_val);
 					}
 				}
 			}
@@ -22441,6 +22398,47 @@ void wlc_phy_stopplayback_nphy(struct brcms_phy *pi)
 		wlc_phy_stay_in_carriersearch_nphy(pi, false);
 }
 
+static u32 *brcms_phy_get_tx_pwrctrl_tbl(struct brcms_phy *pi)
+{
+	u32 *tx_pwrctrl_tbl = NULL;
+	uint phyrev = pi->pubpi.phy_rev;
+
+	if (PHY_IPA(pi)) {
+		tx_pwrctrl_tbl =
+			wlc_phy_get_ipa_gaintbl_nphy(pi);
+	} else {
+		if (CHSPEC_IS5G(pi->radio_chanspec)) {
+			if (NREV_IS(phyrev, 3))
+				tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev3;
+			else if (NREV_IS(phyrev, 4))
+				tx_pwrctrl_tbl =
+					(pi->srom_fem5g.extpagain == 3) ?
+					nphy_tpc_5GHz_txgain_HiPwrEPA :
+					nphy_tpc_5GHz_txgain_rev4;
+			else
+				tx_pwrctrl_tbl = nphy_tpc_5GHz_txgain_rev5;
+		} else {
+			if (NREV_GE(phyrev, 7)) {
+				if (pi->pubpi.radiorev == 3)
+					tx_pwrctrl_tbl =
+						nphy_tpc_txgain_epa_2057rev3;
+				else if (pi->pubpi.radiorev == 5)
+					tx_pwrctrl_tbl =
+						nphy_tpc_txgain_epa_2057rev5;
+			} else {
+				if (NREV_GE(phyrev, 5) &&
+				   (pi->srom_fem2g.extpagain ==	3))
+					tx_pwrctrl_tbl =
+						nphy_tpc_txgain_HiPwrEPA;
+				else
+					tx_pwrctrl_tbl =
+						nphy_tpc_txgain_rev3;
+			}
+		}
+	}
+	return tx_pwrctrl_tbl;
+}
+
 struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi)
 {
 	u16 base_idx[2], curr_gain[2];
@@ -22497,54 +22495,8 @@ struct nphy_txgains wlc_phy_get_tx_gain_nphy(struct brcms_phy *pi)
 		base_idx[1] = (read_phy_reg(pi, 0x1ee) >> 8) & 0x7f;
 		for (core_no = 0; core_no < 2; core_no++) {
 			if (NREV_GE(phyrev, 3)) {
-				if (PHY_IPA(pi)) {
-					tx_pwrctrl_tbl =
-						wlc_phy_get_ipa_gaintbl_nphy(pi);
-				} else {
-					if (CHSPEC_IS5G(pi->radio_chanspec)) {
-						if (NREV_IS(phyrev, 3))
-							tx_pwrctrl_tbl =
-								nphy_tpc_5GHz_txgain_rev3;
-						else if (NREV_IS(phyrev, 4))
-							tx_pwrctrl_tbl =
-								(pi->srom_fem5g
-								 .
-								 extpagain ==
-								 3) ?
-								nphy_tpc_5GHz_txgain_HiPwrEPA
-								:
-								nphy_tpc_5GHz_txgain_rev4;
-						else
-							tx_pwrctrl_tbl =
-								nphy_tpc_5GHz_txgain_rev5;
-					} else {
-						if (NREV_GE(phyrev, 7)) {
-							if (pi->pubpi.
-							    radiorev == 3)
-								tx_pwrctrl_tbl
-									=
-										nphy_tpc_txgain_epa_2057rev3;
-							else if (pi->pubpi.
-								 radiorev ==
-								 5)
-								tx_pwrctrl_tbl
-									=
-										nphy_tpc_txgain_epa_2057rev5;
-						} else {
-							if (NREV_GE(phyrev, 5)
-							    && (pi->srom_fem2g.
-								extpagain ==
-								3))
-								tx_pwrctrl_tbl
-									=
-										nphy_tpc_txgain_HiPwrEPA;
-							else
-								tx_pwrctrl_tbl
-									=
-										nphy_tpc_txgain_rev3;
-						}
-					}
-				}
+				tx_pwrctrl_tbl =
+					brcms_phy_get_tx_pwrctrl_tbl(pi);
 				if (NREV_GE(phyrev, 7)) {
 					target_gain.ipa[core_no] =
 						(tx_pwrctrl_tbl
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 4/19 staging: brcm80211: fixed build issue for big endian platforms

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

Driver now builds for big endian mips platform, possibly also for other big endian platforms. A change was made to the R_REG and W_REG macro's. These macro's perform an xor (^) operation for endianess swap purposes. Gcc complained because an xor operation is not allowed on a pointer type. Fixed this by casting the pointer to an unsigned long.

---
 drivers/staging/brcm80211/brcmsmac/dma.h   |    1 +
 drivers/staging/brcm80211/brcmsmac/types.h |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/staging/brcm80211/brcmsmac/dma.h +1 -0
index 3ff109f..334f2eb 100644
@@ -17,6 +17,7 @@
 #ifndef	_BRCM_DMA_H_
 #define	_BRCM_DMA_H_
 
+#include <linux/delay.h>
 #include "types.h"		/* forward structure declarations */
 
 /* DMA structure:
drivers/staging/brcm80211/brcmsmac/types.h +4 -4
index 6275160..55db3cd 100644
@@ -304,11 +304,11 @@ do {						\
 		switch (sizeof(*(r))) { \
 		case sizeof(u8): \
 			__osl_v = \
-			readb((u8 *)((r)^3)); \
+			readb((u8 *)((unsigned long)(r)^3)); \
 			break; \
 		case sizeof(u16): \
 			__osl_v = \
-			readw((u16 *)((r)^2)); \
+			readw((u16 *)((unsigned long)(r)^2)); \
 			break; \
 		case sizeof(u32): \
 			__osl_v = readl((u32 *)(r)); \
@@ -321,10 +321,10 @@ do {						\
 		switch (sizeof(*(r))) { \
 		case sizeof(u8):	\
 			writeb((u8)(v), \
-			(u8 *)((r)^3)); break; \
+			(u8 *)((unsigned long)(r)^3)); break; \
 		case sizeof(u16):	\
 			writew((u16)(v), \
-			(u16 *)((r)^2)); break; \
+			(u16 *)((unsigned long)(r)^2)); break; \
 		case sizeof(u32):	\
 			writel((u32)(v), \
 			(u32 *)(r)); break; \
Signature · 1 line
1.7.4.1
#5 lore raw

PATCH 5/19 staging: brcm80211: remove MIPS specific 'sync' instruction in fullmac

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

This instruction was required for the bcm4716/bcm4322, but since the fullmac driver only supports bcm4329, it could be removed. After that, the R_REG macro's were identical and thus were reduced to just 1 R_REG macro.

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +0 -18
index 8cb34d6..8224ba4 100644
@@ -35,26 +35,8 @@
 #include "sdio_host.h"
 
 /* register access macros */
-#ifndef __BIG_ENDIAN
-#ifndef __mips__
 #define R_REG(r, typ) \
 	brcmf_sdcard_reg_read(NULL, (r), sizeof(typ))
-#else				/* __mips__ */
-#define R_REG(r, typ) \
-	({ \
-		__typeof(*(r)) __osl_v; \
-		__asm__ __volatile__("sync"); \
-		__osl_v = brcmf_sdcard_reg_read(NULL, (r),\
-					  sizeof(typ)); \
-		__asm__ __volatile__("sync"); \
-		__osl_v; \
-	})
-#endif				/* __mips__ */
-
-#else				/* __BIG_ENDIAN */
-#define R_REG(r, typ) \
-	brcmf_sdcard_reg_read(NULL, (r), sizeof(typ))
-#endif				/* __BIG_ENDIAN */
 
 #define OR_REG(r, v, typ) \
 	brcmf_sdcard_reg_write(NULL, (r), sizeof(typ), R_REG(r, typ) | (v))
Signature · 1 line
1.7.4.1
#8 lore raw

PATCH 8/19 staging: brcm80211: replace simple_strtoul usage in brcmsmac

In reply to Arend van Spriel

The usage of simple_strtoul is not preferred. Instead kstrtoul should be used. This patch fixes this for the brcmsmac driver.

---
 drivers/staging/brcm80211/brcmsmac/main.c        |   16 +++++++++-------
 drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c |    7 ++++---
 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/staging/brcm80211/brcmsmac/main.c +9 -7
index 0d80e59..e5c675d 100644
@@ -4287,16 +4287,17 @@ int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, uint unit,
 #endif
 	if (bustype != SI_BUS) {
 		char *var;
+		unsigned long res;
 
 		var = getvar(vars, "vendid");
-		if (var) {
-			vendor = (u16) simple_strtoul(var, NULL, 0);
+		if (var && !kstrtoul(var, 0, &res)) {
+			vendor = (u16)res;
 			wiphy_err(wiphy, "Overriding vendor id = 0x%x\n",
 				  vendor);
 		}
 		var = getvar(vars, "devid");
-		if (var) {
-			u16 devid = (u16) simple_strtoul(var, NULL, 0);
+		if (var && !kstrtoul(var, 0, &res)) {
+			u16 devid = (u16)res;
 			if (devid != 0xffff) {
 				device = devid;
 				wiphy_err(wiphy, "Overriding device id = 0x%x"
@@ -9596,10 +9597,11 @@ char *getvar(char *vars, const char *name)
 int getintvar(char *vars, const char *name)
 {
 	char *val;
+	unsigned long res;
 
 	val = getvar(vars, name);
-	if (val == NULL)
-		return 0;
+	if (val && !kstrtoul(val, 0, &res))
+		return res;
 
-	return simple_strtoul(val, NULL, 0);
+	return 0;
 }
drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +4 -3
index 582df4a..22f7bfc 100644
@@ -174,12 +174,13 @@ char *phy_getvar(struct brcms_phy *pi, const char *name)
 int phy_getintvar(struct brcms_phy *pi, const char *name)
 {
 	char *val;
+	unsigned long res;
 
 	val = PHY_GETVAR(pi, name);
-	if (val == NULL)
-		return 0;
+	if (val && !kstrtoul(val, 0, &res))
+		return res;
 
-	return simple_strtoul(val, NULL, 0);
+	return 0;
 }
 
 void wlc_phyreg_enter(struct brcms_phy_pub *pih)
Signature · 1 line
1.7.4.1
#9 lore raw

PATCH 9/19 staging: brcm80211: remove private timeout functions in fullmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Use kernel timer macros to replace current private timeout functions used in dhd_sdio.c

---
 drivers/staging/brcm80211/brcmfmac/dhd.h       |   10 ----
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c |   58 ------------------------
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c  |   18 +++++---
 3 files changed, 11 insertions(+), 75 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd.h +0 -10
index f3633fe..1fe9d69 100644
@@ -614,13 +614,6 @@ struct brcmf_if_event {
 	u8 bssidx;
 };
 
-struct brcmf_timeout {
-	u32 limit;		/* Expiration time (usec) */
-	u32 increment;	/* Current expiration increment (usec) */
-	u32 elapsed;		/* Current elapsed time (usec) */
-	u32 tick;		/* O/S tick time (usec) */
-};
-
 struct bcmevent_name {
 	uint event;
 	const char *name;
@@ -783,9 +776,6 @@ extern int brcmf_os_proto_unblock(struct brcmf_pub *drvr);
 extern int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size);
 #endif				/* BCMDBG */
 
-extern void brcmf_timeout_start(struct brcmf_timeout *tmo, uint usec);
-extern int brcmf_timeout_expired(struct brcmf_timeout *tmo);
-
 extern int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name);
 extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx,
 			      void *pktdata, struct brcmf_event_msg *,
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +0 -58

64 lines not on this page · raw message

drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +11 -7
index d02bcc7..7a0d036 100644
@@ -3306,7 +3306,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus, bool enforce_mutex)
 int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex)
 {
 	struct brcmf_bus *bus = drvr->bus;
-	struct brcmf_timeout tmo;
+	unsigned long timeout;
 	uint retries = 0;
 	u8 ready, enable;
 	int err, ret = 0;
@@ -3358,16 +3358,20 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr, bool enforce_mutex)
 	brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable,
 			       NULL);
 
-	/* Give the dongle some time to do its thing and set IOR2 */
-	brcmf_timeout_start(&tmo, BRCMF_WAIT_F2RDY * 1000);
-
+	timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY);
 	ready = 0;
-	while (ready != enable && !brcmf_timeout_expired(&tmo))
+	while (enable != ready) {
 		ready = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_0,
 					      SDIO_CCCR_IORx, NULL);
+		if (time_after(jiffies, timeout))
+			break;
+		else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50))
+			/* prevent busy waiting if it takes too long */
+			msleep_interruptible(20);
+	}
 
-	BRCMF_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
-		    __func__, enable, ready, tmo.elapsed));
+	BRCMF_INFO(("%s: enable 0x%02x, ready 0x%02x\n",
+		    __func__, enable, ready));
 
 	/* If F2 successfully enabled, set core and enable interrupts */
 	if (ready == enable) {
Signature · 1 line
1.7.4.1
#19 lore raw

PATCH 13/19 staging: brcm80211: get rid of sd debug message macro in fullmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Use BRCMF_* instead of sd_* as debug message interface

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c       |    2 -
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |  222 ++++++++-------------
 drivers/staging/brcm80211/brcmfmac/sdio_host.h    |    1 -
 3 files changed, 82 insertions(+), 143 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +0 -2
index 916d41f..310d4fd 100644
@@ -98,8 +98,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
 /* Module parameters specific to each host-controller driver */
 
-module_param(sd_msglevel, uint, 0);
-
 module_param(sd_f2_blocksize, int, 0);
 
 struct brcmf_sdio_card*
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +82 -140

572 lines not on this page · raw message

drivers/staging/brcm80211/brcmfmac/sdio_host.h +0 -1
index ad67955..c33720d 100644
@@ -340,7 +340,6 @@ extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc);
 /* Watchdog timer interface for pm ops */
 extern void brcmf_sdio_wdtmr_enable(bool enable);
 
-extern uint sd_msglevel;	/* Debug message level */
 extern uint sd_f2_blocksize;
 
 extern struct brcmf_sdmmc_instance *gInstance;
Signature · 1 line
1.7.4.1
#20 lore raw

PATCH 14/19 staging: brcm80211: remove structure sdio_hc in brcmfmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Most members in sdio_hc are no longer needed anymore. And fullmac is keeping a global pointer of this structure. This patch deletes the structure and places the useful member to a new structure brcmf_sdio_dev. The pointer of brcmf_sdio_dev will be save in the private driver data during sdio_probe. Therefore, we don't need to keep the global pointer.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c       |   90 ++++-----------------
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |   41 ++++++++--
 drivers/staging/brcm80211/brcmfmac/sdio_host.h    |   18 +++-
 3 files changed, 61 insertions(+), 88 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +15 -75
index 310d4fd..7b66787 100644
@@ -74,25 +74,8 @@ struct brcmf_sdio_card {
 	u32 sbwad;		/* Save backplane window address */
 };
 
-/**
- * SDIO Host Controller info
- */
-struct sdio_hc {
-	struct sdio_hc *next;
-	struct device *dev;	/* platform device handle */
-	void *regs;		/* SDIO Host Controller address */
-	struct brcmf_sdio_card *card;
-	void *ch;
-	unsigned int oob_irq;
-	unsigned long oob_flags;	/* OOB Host specifiction
-					as edge and etc */
-	bool oob_irq_registered;
-};
-
 const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL;
 
-static struct sdio_hc *sdhcinfo;
-
 /* driver info, initialized when brcmf_sdio_register is called */
 static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
@@ -101,7 +84,7 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 module_param(sd_f2_blocksize, int, 0);
 
 struct brcmf_sdio_card*
-brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq)
+brcmf_sdcard_attach(void *cfghdl, u32 *regsva)
 {
 	struct brcmf_sdio_card *card;
 
@@ -111,7 +94,7 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq)
 		return NULL;
 	}
 
-	card->sdioh = brcmf_sdioh_attach(cfghdl, irq);
+	card->sdioh = brcmf_sdioh_attach(cfghdl);
 	if (!card->sdioh) {
 		brcmf_sdcard_detach(card);
 		return NULL;
@@ -495,44 +478,26 @@ u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card)
 	return card->sbwad;
 }
 
-int brcmf_sdio_probe(struct device *dev)
+int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 {
-	struct sdio_hc *sdhc = NULL;
 	u32 regs = 0;
 	struct brcmf_sdio_card *card = NULL;
-	int irq = 0;
 	u32 vendevid;
-	unsigned long irq_flags = 0;
-
-	/* allocate SDIO Host Controller state info */
-	sdhc = kzalloc(sizeof(struct sdio_hc), GFP_ATOMIC);
-	if (!sdhc) {
-		SDLX_MSG(("%s: out of memory\n", __func__));
-		goto err;
-	}
-	sdhc->dev = (void *)dev;
 
-	card = brcmf_sdcard_attach((void *)0, &regs, irq);
+	card = brcmf_sdcard_attach((void *)0, &regs);
 	if (!card) {
 		SDLX_MSG(("%s: attach failed\n", __func__));
 		goto err;
 	}
+	sdiodev->card = card;
 
-	sdhc->card = card;
-	sdhc->oob_irq = irq;
-	sdhc->oob_flags = irq_flags;
-	sdhc->oob_irq_registered = false;	/* to make sure.. */
-
-	/* chain SDIO Host Controller info together */
-	sdhc->next = sdhcinfo;
-	sdhcinfo = sdhc;
 	/* Read the vendor/device ID from the CIS */
 	vendevid = brcmf_sdcard_query_device(card);
 
 	/* try to attach to the target device */
-	sdhc->ch = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF),
+	sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF),
 				  0, 0, 0, 0, regs, card);
-	if (!sdhc->ch) {
+	if (!sdiodev->bus) {
 		SDLX_MSG(("%s: device attach failed\n", __func__));
 		goto err;
 	}
@@ -541,42 +506,17 @@ int brcmf_sdio_probe(struct device *dev)
 
 	/* error handling */
 err:
-	if (sdhc) {
-		if (sdhc->card)
-			brcmf_sdcard_detach(sdhc->card);
-		kfree(sdhc);
-	}
+	if (sdiodev->card)
+		brcmf_sdcard_detach(sdiodev->card);
 
 	return -ENODEV;
 }
 EXPORT_SYMBOL(brcmf_sdio_probe);
 
-int brcmf_sdio_remove(struct device *dev)
+int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev)
 {
-	struct sdio_hc *sdhc, *prev;
-
-	sdhc = sdhcinfo;
-	drvinfo.detach(sdhc->ch);
-	brcmf_sdcard_detach(sdhc->card);
-	/* find the SDIO Host Controller state for this pdev
-		 and take it out from the list */
-	for (sdhc = sdhcinfo, prev = NULL; sdhc; sdhc = sdhc->next) {
-		if (sdhc->dev == (void *)dev) {
-			if (prev)
-				prev->next = sdhc->next;
-			else
-				sdhcinfo = NULL;
-			break;
-		}
-		prev = sdhc;
-	}
-	if (!sdhc) {
-		SDLX_MSG(("%s: failed\n", __func__));
-		return 0;
-	}
-
-	/* release SDIO Host Controller info */
-	kfree(sdhc);
+	drvinfo.detach(sdiodev->bus);
+	brcmf_sdcard_detach(sdiodev->card);
 	return 0;
 }
 EXPORT_SYMBOL(brcmf_sdio_remove);
@@ -594,10 +534,10 @@ void brcmf_sdio_unregister(void)
 	brcmf_sdio_function_cleanup();
 }
 
-void brcmf_sdio_wdtmr_enable(bool enable)
+void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable)
 {
 	if (enable)
-		brcmf_sdbrcm_wd_timer(sdhcinfo->ch, brcmf_watchdog_ms);
+		brcmf_sdbrcm_wd_timer(sdiodev->bus, brcmf_watchdog_ms);
 	else
-		brcmf_sdbrcm_wd_timer(sdhcinfo->ch, 0);
+		brcmf_sdbrcm_wd_timer(sdiodev->bus, 0);
 }
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +33 -8

109 lines not on this page · raw message

drivers/staging/brcm80211/brcmfmac/sdio_host.h +13 -5
index c33720d..9853e74 100644
@@ -130,6 +130,13 @@ struct brcmf_sdmmc_instance {
 	u32 host_claimed;
 };
 
+struct brcmf_sdio_dev {
+	struct sdio_func *func1;
+	struct sdio_func *func2;
+	struct brcmf_sdio_card *card;
+	void *bus;
+};
+
 /* Attach and build an interface to the underlying SD host driver.
  *  - Allocates resources (structs, arrays, mem, OS handles, etc) needed by
  *    brcmf_sdcard.
@@ -139,7 +146,7 @@ struct brcmf_sdmmc_instance {
  *    most recent one) to enable single-instance implementations to pass NULL.
  */
 extern struct brcmf_sdio_card*
-brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq);
+brcmf_sdcard_attach(void *cfghdl, u32 *regsva);
 
 /* Detach - freeup resources allocated in attach */
 extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card);
@@ -272,8 +279,8 @@ extern int brcmf_sdio_function_init(void);
 extern int brcmf_sdio_register(struct brcmf_sdioh_driver *driver);
 extern void brcmf_sdio_unregister(void);
 extern void brcmf_sdio_function_cleanup(void);
-extern int brcmf_sdio_probe(struct device *dev);
-extern int brcmf_sdio_remove(struct device *dev);
+extern int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev);
+extern int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev);
 
 /* Function to return current window addr */
 extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card);
@@ -290,7 +297,7 @@ extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd);
  *  The handler shall be provided by all subsequent calls. No local cache
  *  cfghdl points to the starting address of pci device mapped memory
  */
-extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl, uint irq);
+extern struct sdioh_info *brcmf_sdioh_attach(void *cfghdl);
 extern int brcmf_sdioh_detach(struct sdioh_info *si);
 
 extern int
@@ -338,7 +345,8 @@ extern int brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name,
 extern int brcmf_sdioh_abort(struct sdioh_info *si, uint fnc);
 
 /* Watchdog timer interface for pm ops */
-extern void brcmf_sdio_wdtmr_enable(bool enable);
+extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev,
+				    bool enable);
 
 extern uint sd_f2_blocksize;
 
Signature · 1 line
1.7.4.1
#22 lore raw

PATCH 16/19 staging: brcm80211: remove BRCMF_SD_* debug macros from brcmfmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Use unified debug macros BRCMF_* in fullmac.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c    |   50 ++++++-----------------
 drivers/staging/brcm80211/brcmfmac/sdio_host.h |    1 -
 2 files changed, 13 insertions(+), 38 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +13 -37
index 0953160..53dfecd 100644
@@ -34,28 +34,6 @@
 
 #define SDIOH_API_ACCESS_RETRY_LIMIT	2
 
-#define BRCMF_SD_ERROR_VAL	0x0001	/* Error */
-#define BRCMF_SD_INFO_VAL		0x0002	/* Info */
-
-
-#ifdef BCMDBG
-#define BRCMF_SD_ERROR(x) \
-	do { \
-		if ((brcmf_sdio_msglevel & BRCMF_SD_ERROR_VAL) && \
-		    net_ratelimit()) \
-			printk x; \
-	} while (0)
-#define BRCMF_SD_INFO(x)	\
-	do { \
-		if ((brcmf_sdio_msglevel & BRCMF_SD_INFO_VAL) && \
-		    net_ratelimit()) \
-			printk x; \
-	} while (0)
-#else				/* BCMDBG */
-#define BRCMF_SD_ERROR(x)
-#define BRCMF_SD_INFO(x)
-#endif				/* BCMDBG */
-
 #define SDIOH_CMD_TYPE_NORMAL   0	/* Normal command */
 #define SDIOH_CMD_TYPE_APPEND   1	/* Append command */
 #define SDIOH_CMD_TYPE_CUTTHRU  2	/* Cut-through command */
@@ -72,8 +50,6 @@ struct brcmf_sdio_card {
 	u32 sbwad;		/* Save backplane window address */
 };
 
-const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL;
-
 /* driver info, initialized when brcmf_sdio_register is called */
 static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
@@ -88,7 +64,7 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva)
 
 	card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC);
 	if (card == NULL) {
-		BRCMF_SD_ERROR(("sdcard_attach: out of memory"));
+		BRCMF_ERROR(("sdcard_attach: out of memory"));
 		return NULL;
 	}
 
@@ -167,7 +143,7 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
 	if (err)
 		*err = status;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
 		     __func__, fnc_num, addr, data));
 
 	return data;
@@ -191,7 +167,7 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
 	if (err)
 		*err = status;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u8data = 0x%x\n",
 		     __func__, fnc_num, addr, data));
 }
 
@@ -207,7 +183,7 @@ u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num,
 	if (err)
 		*err = status;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
 		     __func__, fnc_num, addr, data));
 
 	return data;
@@ -226,7 +202,7 @@ brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num,
 	if (err)
 		*err = status;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, u32data = 0x%x\n",
 		     __func__, fnc_num, addr, data));
 }
 
@@ -247,7 +223,7 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis,
 			 into the provided buffer. */
 		tmp_buf = kmalloc(length, GFP_ATOMIC);
 		if (tmp_buf == NULL) {
-			BRCMF_SD_ERROR(("%s: out of memory\n", __func__));
+			BRCMF_ERROR(("%s: out of memory\n", __func__));
 			return -ENOMEM;
 		}
 		memcpy(tmp_buf, cis, length);
@@ -289,7 +265,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size)
 	u32 word = 0;
 	uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
 
-	BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr));
+	BRCMF_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr));
 
 	if (bar0 != card->sbwad) {
 		if (brcmf_sdcard_set_sbaddr_window(card, bar0))
@@ -307,7 +283,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size)
 
 	card->regfail = (status != 0);
 
-	BRCMF_SD_INFO(("u32data = 0x%x\n", word));
+	BRCMF_INFO(("u32data = 0x%x\n", word));
 
 	/* if ok, return appropriately masked word */
 	if (status == 0) {
@@ -325,7 +301,7 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size)
 	}
 
 	/* otherwise, bad sdio access or invalid size */
-	BRCMF_SD_ERROR(("%s: error reading addr 0x%04x size %d\n", __func__,
+	BRCMF_ERROR(("%s: error reading addr 0x%04x size %d\n", __func__,
 		      addr, size));
 	return 0xFFFFFFFF;
 }
@@ -337,7 +313,7 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size,
 	uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
 	int err = 0;
 
-	BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n",
+	BRCMF_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n",
 		     __func__, addr, size * 8, data));
 
 	if (bar0 != card->sbwad) {
@@ -359,7 +335,7 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size,
 	if (status == 0)
 		return 0;
 
-	BRCMF_SD_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n",
+	BRCMF_ERROR(("%s: error writing 0x%08x to addr 0x%04x size %d\n",
 		      __func__, data, addr, size));
 	return 0xFFFFFFFF;
 }
@@ -383,7 +359,7 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
 	uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
 	int err = 0;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n",
 		     __func__, fn, addr, nbytes));
 
 	/* Async not implemented yet */
@@ -423,7 +399,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
 	uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
 	int err = 0;
 
-	BRCMF_SD_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n",
+	BRCMF_INFO(("%s:fun = %d, addr = 0x%x, size = %d\n",
 		     __func__, fn, addr, nbytes));
 
 	/* Async not implemented yet */
drivers/staging/brcm80211/brcmfmac/sdio_host.h +0 -1
index 9853e74..5e7552e 100644
@@ -18,7 +18,6 @@
 #define	_BRCM_SDH_H_
 
 #include <linux/skbuff.h>
-extern const uint brcmf_sdio_msglevel;
 
 #define SDIO_FUNC_0		0
 #define SDIO_FUNC_1		1
Signature · 1 line
1.7.4.1
#24 lore raw

PATCH 18/19 staging: brcm80211: absorb brcmf_sdcard_detach into brcmf_sdio_remove

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

To increase code readability of brcmfmac

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c    |   32 ++++++++++-------------
 drivers/staging/brcm80211/brcmfmac/sdio_host.h |    3 --
 2 files changed, 14 insertions(+), 21 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +14 -18
index 6f88bd2..0cd449d 100644
@@ -57,19 +57,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
 module_param(sd_f2_blocksize, int, 0);
 
-int brcmf_sdcard_detach(struct brcmf_sdio_card *card)
-{
-	if (card != NULL) {
-		if (card->sdioh) {
-			brcmf_sdioh_detach(card->sdioh);
-			card->sdioh = NULL;
-		}
-		kfree(card);
-	}
-
-	return 0;
-}
-
 int
 brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name,
 		void *params, int plen, void *arg, int len, bool set)
@@ -441,7 +428,6 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 
 	sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0);
 	if (!sdiodev->card->sdioh) {
-		brcmf_sdcard_detach(sdiodev->card);
 		ret = -ENODEV;
 		goto out;
 	}
@@ -466,8 +452,8 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 	}
 
 out:
-	if ((ret) && (sdiodev->card))
-		brcmf_sdcard_detach(sdiodev->card);
+	if (ret)
+		brcmf_sdio_remove(sdiodev);
 
 	return ret;
 }
@@ -475,8 +461,18 @@ EXPORT_SYMBOL(brcmf_sdio_probe);
 
 int brcmf_sdio_remove(struct brcmf_sdio_dev *sdiodev)
 {
-	drvinfo.detach(sdiodev->bus);
-	brcmf_sdcard_detach(sdiodev->card);
+	if (sdiodev->bus) {
+		drvinfo.detach(sdiodev->bus);
+		sdiodev->bus = NULL;
+	}
+
+	if (sdiodev->card) {
+		if (sdiodev->card->sdioh)
+			brcmf_sdioh_detach(sdiodev->card->sdioh);
+		kfree(sdiodev->card);
+		sdiodev->card = NULL;
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL(brcmf_sdio_remove);
drivers/staging/brcm80211/brcmfmac/sdio_host.h +0 -3
index 68b6843..cf3b8fc 100644
@@ -136,9 +136,6 @@ struct brcmf_sdio_dev {
 	void *bus;
 };
 
-/* Detach - freeup resources allocated in attach */
-extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card);
-
 /* Enable/disable SD interrupt */
 extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card);
 extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card);
Signature · 1 line
1.7.4.1
#6 lore raw

PATCH 6/19 staging: brcm80211: removed R_REG and OR_REG macro's from fullmac

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

Code cleanup. Macro invocations have been substituted with macro expansion.

---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +9 -11
index 8224ba4..27a6937 100644
@@ -34,13 +34,6 @@
 #include <soc.h>
 #include "sdio_host.h"
 
-/* register access macros */
-#define R_REG(r, typ) \
-	brcmf_sdcard_reg_read(NULL, (r), sizeof(typ))
-
-#define OR_REG(r, v, typ) \
-	brcmf_sdcard_reg_write(NULL, (r), sizeof(typ), R_REG(r, typ) | (v))
-
 #ifdef BCMDBG
 
 /* ARM trap handling */
@@ -896,7 +889,8 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar)
 {
 	*retryvar = 0;
 	do {
-		*regvar = R_REG(bus->ci->buscorebase + reg_offset, u32);
+		*regvar = brcmf_sdcard_reg_read(NULL,
+				bus->ci->buscorebase + reg_offset, sizeof(u32));
 	} while (brcmf_sdcard_regfail(bus->card) &&
 		 (++(*retryvar) <= retry_limit));
 	if (*retryvar) {
@@ -5618,6 +5612,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva,
 {
 	u8 clkctl = 0;
 	int err = 0;
+	int reg_addr;
+	u32 reg_val;
 
 	bus->alp_only = true;
 
@@ -5684,9 +5680,11 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva,
 	}
 
 	/* Set core control so an SDIO reset does a backplane reset */
-	OR_REG(bus->ci->buscorebase + offsetof(struct sdpcmd_regs,
-						       corecontrol),
-	       CC_BPRESEN, u32);
+	reg_addr = bus->ci->buscorebase +
+		   offsetof(struct sdpcmd_regs, corecontrol);
+	reg_val = brcmf_sdcard_reg_read(NULL, reg_addr, sizeof(u32));
+	brcmf_sdcard_reg_write(NULL, reg_addr, sizeof(u32),
+			       reg_val | CC_BPRESEN);
 
 	brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
 
Signature · 1 line
1.7.4.1
#7 lore raw

PATCH 7/19 staging: brcm80211: removed global variable from sdio fullmac

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

Code cleanup. bus->card is assigned in brcmf_sdbrcm_probe (before brcmf_sdbrcm_probe_attach()). Since w_sdreg32() and r_sdreg32() are called only after that assignment, they can safely use bus->card. Thus there is no instance left where brcmf_sdcard_reg_read() or brcmf_sdcard_reg_write() is called with a NULL parameter, so the mechanism in bcmsdh.c that deals with a NULL pointer could be deleted.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c   |   31 -------------------------
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |    9 ++++---
 2 files changed, 5 insertions(+), 35 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +0 -31
index fb3ab63..916d41f 100644
@@ -89,9 +89,6 @@ struct sdio_hc {
 	bool oob_irq_registered;
 };
 
-/* local copy of bcm sd handler */
-static struct brcmf_sdio_card *l_card;
-
 const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL;
 
 static struct sdio_hc *sdhcinfo;
@@ -116,9 +113,6 @@ brcmf_sdcard_attach(void *cfghdl, u32 *regsva, uint irq)
 		return NULL;
 	}
 
-	/* save the handler locally */
-	l_card = card;
-
 	card->sdioh = brcmf_sdioh_attach(cfghdl, irq);
 	if (!card->sdioh) {
 		brcmf_sdcard_detach(card);
@@ -144,7 +138,6 @@ int brcmf_sdcard_detach(struct brcmf_sdio_card *card)
 		kfree(card);
 	}
 
-	l_card = NULL;
 	return 0;
 }
 
@@ -184,9 +177,6 @@ u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
 	s32 retry = 0;
 	u8 data = 0;
 
-	if (!card)
-		card = l_card;
-
 	do {
 		if (retry)	/* wait for 1 ms till bus get settled down */
 			udelay(1000);
@@ -211,9 +201,6 @@ brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
 	int status;
 	s32 retry = 0;
 
-	if (!card)
-		card = l_card;
-
 	do {
 		if (retry)	/* wait for 1 ms till bus get settled down */
 			udelay(1000);
@@ -235,9 +222,6 @@ u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num,
 	int status;
 	u32 data = 0;
 
-	if (!card)
-		card = l_card;
-
 	status = brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL,
 		SDIOH_READ, fnc_num, addr, &data, 4);
 
@@ -256,9 +240,6 @@ brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num,
 {
 	int status;
 
-	if (!card)
-		card = l_card;
-
 	status =
 	    brcmf_sdioh_request_word(card->sdioh, SDIOH_CMD_TYPE_NORMAL,
 			       SDIOH_WRITE, fnc_num, addr, &data, 4);
@@ -280,9 +261,6 @@ int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis,
 	bool ascii = func & ~0xf;
 	func &= 0x7;
 
-	if (!card)
-		card = l_card;
-
 	status = brcmf_sdioh_cis_read(card->sdioh, func, cis, length);
 
 	if (ascii) {
@@ -334,9 +312,6 @@ u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size)
 
 	BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, ", __func__, addr));
 
-	if (!card)
-		card = l_card;
-
 	if (bar0 != card->sbwad) {
 		if (brcmf_sdcard_set_sbaddr_window(card, bar0))
 			return 0xFFFFFFFF;
@@ -386,9 +361,6 @@ u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size,
 	BRCMF_SD_INFO(("%s:fun = 1, addr = 0x%x, uint%ddata = 0x%x\n",
 		     __func__, addr, size * 8, data));
 
-	if (!card)
-		card = l_card;
-
 	if (bar0 != card->sbwad) {
 		err = brcmf_sdcard_set_sbaddr_window(card, bar0);
 		if (err)
@@ -522,9 +494,6 @@ int brcmf_sdcard_query_device(struct brcmf_sdio_card *card)
 
 u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card)
 {
-	if (!card)
-		card = l_card;
-
 	return card->sbwad;
 }
 
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +5 -4
index 27a6937..d02bcc7 100644
@@ -889,7 +889,7 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar)
 {
 	*retryvar = 0;
 	do {
-		*regvar = brcmf_sdcard_reg_read(NULL,
+		*regvar = brcmf_sdcard_reg_read(bus->card,
 				bus->ci->buscorebase + reg_offset, sizeof(u32));
 	} while (brcmf_sdcard_regfail(bus->card) &&
 		 (++(*retryvar) <= retry_limit));
@@ -907,7 +907,8 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar)
 {
 	*retryvar = 0;
 	do {
-		brcmf_sdcard_reg_write(NULL, bus->ci->buscorebase + reg_offset,
+		brcmf_sdcard_reg_write(bus->card,
+				       bus->ci->buscorebase + reg_offset,
 				       sizeof(u32), regval);
 	} while (brcmf_sdcard_regfail(bus->card) &&
 		 (++(*retryvar) <= retry_limit));
@@ -5682,8 +5683,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, void *card, u32 regsva,
 	/* Set core control so an SDIO reset does a backplane reset */
 	reg_addr = bus->ci->buscorebase +
 		   offsetof(struct sdpcmd_regs, corecontrol);
-	reg_val = brcmf_sdcard_reg_read(NULL, reg_addr, sizeof(u32));
-	brcmf_sdcard_reg_write(NULL, reg_addr, sizeof(u32),
+	reg_val = brcmf_sdcard_reg_read(bus->card, reg_addr, sizeof(u32));
+	brcmf_sdcard_reg_write(bus->card, reg_addr, sizeof(u32),
 			       reg_val | CC_BPRESEN);
 
 	brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
Signature · 1 line
1.7.4.1
#10 lore raw

PATCH 10/19 staging: brcm80211: move brcmf_mmc_suspend to sdio layer in fullmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

brcmf_mmc_suspend is used for sdio suspend/resume function. Hence it should be placed in sdio interface layer.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |   38 +++++++++++++++-----
 drivers/staging/brcm80211/brcmfmac/dhd.h          |   17 ---------
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c    |    8 ----
 drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c  |    8 ----
 4 files changed, 28 insertions(+), 43 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +28 -10
index bfe73ee..d6f0f92 100644
@@ -143,6 +143,7 @@ module_param(clockoverride, int, 0644);
 MODULE_PARM_DESC(clockoverride, "SDIO card clock override");
 
 struct brcmf_sdmmc_instance *gInstance;
+static atomic_t brcmf_mmc_suspend;
 
 struct device sdmmc_dev;
 
@@ -157,31 +158,44 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
 	{ /* end: all zeroes */ },
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static const struct dev_pm_ops brcmf_sdio_pm_ops = {
 	.suspend	= brcmf_sdio_suspend,
 	.resume		= brcmf_sdio_resume,
 };
-#endif	/* CONFIG_PM */
+#endif	/* CONFIG_PM_SLEEP */
 
 static struct sdio_driver brcmf_sdmmc_driver = {
 	.probe = brcmf_ops_sdio_probe,
 	.remove = brcmf_ops_sdio_remove,
 	.name = "brcmfmac",
 	.id_table = brcmf_sdmmc_ids,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 	.drv = {
 		.pm = &brcmf_sdio_pm_ops,
 	},
-#endif	/* CONFIG_PM */
+#endif	/* CONFIG_PM_SLEEP */
 };
 
 MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
 
-BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_byte_wait);
-BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_word_wait);
-BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_packet_wait);
-BRCMF_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait);
+#ifdef CONFIG_PM_SLEEP
+DECLARE_WAIT_QUEUE_HEAD(sdioh_request_byte_wait);
+DECLARE_WAIT_QUEUE_HEAD(sdioh_request_word_wait);
+DECLARE_WAIT_QUEUE_HEAD(sdioh_request_packet_wait);
+DECLARE_WAIT_QUEUE_HEAD(sdioh_request_buffer_wait);
+#define BRCMF_PM_RESUME_WAIT(a) do { \
+		int retry = 0; \
+		while (atomic_read(&brcmf_mmc_suspend) && retry++ != 30) { \
+			wait_event_timeout(a, false, HZ/100); \
+		} \
+	}	while (0)
+#define BRCMF_PM_RESUME_RETURN_ERROR(a)	\
+	do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
+#else
+#define BRCMF_PM_RESUME_WAIT(a)
+#define BRCMF_PM_RESUME_RETURN_ERROR(a)
+#endif		/* CONFIG_PM_SLEEP */
 
 static int
 brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr,
@@ -1049,6 +1063,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
 			sd_trace(("NIC found, calling brcmf_sdio_probe...\n"));
 			ret = brcmf_sdio_probe(&sdmmc_dev);
 		}
+		atomic_set(&brcmf_mmc_suspend, false);
 	}
 
 	gInstance->func[func->num] = func;
@@ -1077,7 +1092,7 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func)
 }
 
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int brcmf_sdio_suspend(struct device *dev)
 {
 	mmc_pm_flag_t sdio_flags;
@@ -1085,6 +1100,8 @@ static int brcmf_sdio_suspend(struct device *dev)
 
 	sd_trace(("%s\n", __func__));
 
+	atomic_set(&brcmf_mmc_suspend, true);
+
 	sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]);
 	if (!(sdio_flags & MMC_PM_KEEP_POWER)) {
 		sd_err(("Host can't keep power while suspended\n"));
@@ -1105,9 +1122,10 @@ static int brcmf_sdio_suspend(struct device *dev)
 static int brcmf_sdio_resume(struct device *dev)
 {
 	brcmf_sdio_wdtmr_enable(true);
+	atomic_set(&brcmf_mmc_suspend, false);
 	return 0;
 }
-#endif		/* CONFIG_PM */
+#endif		/* CONFIG_PM_SLEEP */
 
 int brcmf_sdioh_osinit(struct sdioh_info *sd)
 {
drivers/staging/brcm80211/brcmfmac/dhd.h +0 -17
index 1fe9d69..9afd9ff 100644
@@ -620,18 +620,6 @@ struct bcmevent_name {
 };
 
 #if defined(CONFIG_PM_SLEEP)
-extern atomic_t brcmf_mmc_suspend;
-#define BRCMF_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
-#define _BRCMF_PM_RESUME_WAIT(a, b) do { \
-		int retry = 0; \
-		while (atomic_read(&brcmf_mmc_suspend) && retry++ != b) { \
-			wait_event_timeout(a, false, HZ/100); \
-		} \
-	}	while (0)
-#define BRCMF_PM_RESUME_WAIT(a)	_BRCMF_PM_RESUME_WAIT(a, 30)
-#define BRCMF_PM_RESUME_RETURN_ERROR(a)	\
-	do { if (atomic_read(&brcmf_mmc_suspend)) return a; } while (0)
-
 #define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
 #define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
 		uint countdown = (us) + 9999; \
@@ -642,11 +630,6 @@ extern atomic_t brcmf_mmc_suspend;
 	} while (0)
 
 #else
-
-#define BRCMF_PM_RESUME_WAIT_INIT(a)
-#define BRCMF_PM_RESUME_WAIT(a)
-#define BRCMF_PM_RESUME_RETURN_ERROR(a)
-
 #define BRCMF_SPINWAIT_SLEEP_INIT(a)
 #define BRCMF_SPINWAIT_SLEEP(a, exp, us)  do { \
 		uint countdown = (us) + 9; \
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +0 -8
index 8319237..54b09e0 100644
@@ -42,11 +42,6 @@
 #include "wl_cfg80211.h"
 #include "bcmchip.h"
 
-#if defined(CONFIG_PM_SLEEP)
-#include <linux/suspend.h>
-atomic_t brcmf_mmc_suspend;
-#endif	/*  defined(CONFIG_PM_SLEEP) */
-
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver.");
 MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards");
@@ -1273,9 +1268,6 @@ struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen)
 	 */
 	memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv));
 
-#if defined(CONFIG_PM_SLEEP)
-	atomic_set(&brcmf_mmc_suspend, false);
-#endif	/* defined(CONFIG_PM_SLEEP) */
 	return &drvr_priv->pub;
 
 fail:
drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +0 -8
index 1199397..ae0a7eb 100644
@@ -2102,10 +2102,6 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy)
 	 */
 	WL_TRACE("Enter\n");
 
-#if defined(CONFIG_PM_SLEEP)
-	atomic_set(&brcmf_mmc_suspend, false);
-#endif	/*  defined(CONFIG_PM_SLEEP) */
-
 	if (test_bit(WL_STATUS_READY, &cfg_priv->status))
 		brcmf_invoke_iscan(wiphy_to_cfg(wiphy));
 
@@ -2167,10 +2163,6 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy,
 		brcmf_set_mpc(ndev, 1);
 	}
 
-#if defined(CONFIG_PM_SLEEP)
-	atomic_set(&brcmf_mmc_suspend, true);
-#endif	/*  defined(CONFIG_PM_SLEEP) */
-
 	WL_TRACE("Exit\n");
 
 	return 0;
Signature · 1 line
1.7.4.1
#11 lore raw

PATCH 11/19 staging: brcm80211: remove global wait queue head sdioh_spinwait_sleep

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Remove global wait queue head sdioh_spinwait_sleep in fullmac.

---
 drivers/staging/brcm80211/brcmfmac/dhd.h      |   22 ----------------------
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c |   21 +++++++++++----------
 2 files changed, 11 insertions(+), 32 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd.h +0 -22
index 9afd9ff..3c950cc 100644
@@ -619,28 +619,6 @@ struct bcmevent_name {
 	const char *name;
 };
 
-#if defined(CONFIG_PM_SLEEP)
-#define BRCMF_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
-#define BRCMF_SPINWAIT_SLEEP(a, exp, us) do { \
-		uint countdown = (us) + 9999; \
-		while ((exp) && (countdown >= 10000)) { \
-			wait_event_timeout(a, false, HZ/100); \
-			countdown -= 10000; \
-		} \
-	} while (0)
-
-#else
-#define BRCMF_SPINWAIT_SLEEP_INIT(a)
-#define BRCMF_SPINWAIT_SLEEP(a, exp, us)  do { \
-		uint countdown = (us) + 9; \
-		while ((exp) && (countdown >= 10)) { \
-			udelay(10);  \
-			countdown -= 10;  \
-		} \
-	} while (0)
-
-#endif	/* defined(CONFIG_PM_SLEEP) */
-
 /*
  * Insmod parameters for debug/test
  */
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +11 -10
index 7a0d036..e9806c3 100644
@@ -444,8 +444,6 @@ struct rte_console {
 	(((prio) == PRIO_8021D_NONE || (prio) == PRIO_8021D_BE) ? \
 	((prio^2)) : (prio))
 
-BRCMF_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep);
-
 /*
  * Core reg address translation.
  * Both macro's returns a 32 bits byte address on the backplane bus.
@@ -1033,6 +1031,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok)
 	int err;
 	u8 clkctl, clkreq, devctl;
 	struct brcmf_sdio_card *card;
+	unsigned long timeout;
 
 	BRCMF_TRACE(("%s: Enter\n", __func__));
 
@@ -1102,14 +1101,16 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok)
 		}
 
 		/* Otherwise, wait here (polling) for HT Avail */
-		if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
-			BRCMF_SPINWAIT_SLEEP(sdioh_spinwait_sleep,
-			       ((clkctl =
-				 brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
-					 SBSDIO_FUNC1_CHIPCLKCSR,
-						 &err)),
-				!SBSDIO_CLKAV(clkctl, bus->alp_only)),
-			       PMU_MAX_TRANSITION_DLY);
+		timeout = jiffies +
+			  msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000);
+		while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
+			clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
+						       SBSDIO_FUNC1_CHIPCLKCSR,
+						       &err);
+			if (time_after(jiffies, timeout))
+				break;
+			else
+				usleep_range(5000, 10000);
 		}
 		if (err) {
 			BRCMF_ERROR(("%s: HT Avail request error: %d\n",
Signature · 1 line
1.7.4.1
#12 lore raw

PATCH 12/19 staging: brcm80211: remove code for unsupported chip

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Currently fullmac only support bcm4329. Remove dead code for unsupported chip.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |   40 +-------------------
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c     |   17 +--------
 2 files changed, 3 insertions(+), 54 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +2 -38
index d6f0f92..846b6be 100644
@@ -34,36 +34,17 @@
 #include "dhd_dbg.h"
 #include "wl_cfg80211.h"
 
-#define BLOCK_SIZE_64 64
-#define BLOCK_SIZE_512 512
-#define BLOCK_SIZE_4318 64
-#define BLOCK_SIZE_4328 512
-
-/* private bus modes */
-#define SDIOH_MODE_SD4		2
-
 #define CLIENT_INTR		0x100	/* Get rid of this! */
 
 #if !defined(SDIO_VENDOR_ID_BROADCOM)
 #define SDIO_VENDOR_ID_BROADCOM		0x02d0
 #endif				/* !defined(SDIO_VENDOR_ID_BROADCOM) */
 
-#define SDIO_DEVICE_ID_BROADCOM_DEFAULT	0x0000
-
 #define DMA_ALIGN_MASK	0x03
 
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)
-#define SDIO_DEVICE_ID_BROADCOM_4325_SDGWB	0x0492	/* BCM94325SDGWB */
-#endif		/* !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) */
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4325)
-#define SDIO_DEVICE_ID_BROADCOM_4325	0x0493
-#endif		/* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
 #if !defined(SDIO_DEVICE_ID_BROADCOM_4329)
 #define SDIO_DEVICE_ID_BROADCOM_4329	0x4329
 #endif		/* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */
-#if !defined(SDIO_DEVICE_ID_BROADCOM_4319)
-#define SDIO_DEVICE_ID_BROADCOM_4319	0x4319
-#endif		/* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */
 
 /* Common msglevel constants */
 #define SDH_ERROR_VAL		0x0001	/* Error */
@@ -136,12 +117,6 @@ uint sd_f2_blocksize = 512;	/* Default blocksize */
 
 uint sd_msglevel = 0x01;
 
-/* module param defaults */
-static int clockoverride;
-
-module_param(clockoverride, int, 0644);
-MODULE_PARM_DESC(clockoverride, "SDIO card clock override");
-
 struct brcmf_sdmmc_instance *gInstance;
 static atomic_t brcmf_mmc_suspend;
 
@@ -149,12 +124,7 @@ struct device sdmmc_dev;
 
 /* devices we support, null terminated */
 static const struct sdio_device_id brcmf_sdmmc_ids[] = {
-	{SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_DEFAULT)},
-	{SDIO_DEVICE
-	 (SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)},
-	{SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325)},
 	{SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)},
-	{SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4319)},
 	{ /* end: all zeroes */ },
 };
 
@@ -498,10 +468,10 @@ brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name,
 				maxsize = 32;
 				break;
 			case 1:
-				maxsize = BLOCK_SIZE_4318;
+				maxsize = 64;
 				break;
 			case 2:
-				maxsize = BLOCK_SIZE_4328;
+				maxsize = 512;
 				break;
 			default:
 				maxsize = 0;
@@ -1058,12 +1028,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
 		sdio_func_0.num = 0;
 		sdio_func_0.card = func->card;
 		gInstance->func[0] = &sdio_func_0;
-		if (func->device == 0x4) {	/* 4318 */
-			gInstance->func[2] = NULL;
-			sd_trace(("NIC found, calling brcmf_sdio_probe...\n"));
-			ret = brcmf_sdio_probe(&sdmmc_dev);
-		}
-		atomic_set(&brcmf_mmc_suspend, false);
 	}
 
 	gInstance->func[func->num] = func;
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +1 -16
index e9806c3..fe11478 100644
@@ -1273,8 +1273,7 @@ int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep)
 			SBSDIO_FORCE_HW_CLKREQ_OFF, NULL);
 
 		/* Isolate the bus */
-		if (bus->ci->chip != BCM4329_CHIP_ID
-		    && bus->ci->chip != BCM4319_CHIP_ID) {
+		if (bus->ci->chip != BCM4329_CHIP_ID) {
 			brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
 				SBSDIO_DEVICE_CTL,
 				SBSDIO_DEVCTL_PADS_ISO, NULL);
@@ -5401,12 +5400,8 @@ done:
 
 static bool brcmf_sdbrcm_chipmatch(u16 chipid)
 {
-	if (chipid == BCM4325_CHIP_ID)
-		return true;
 	if (chipid == BCM4329_CHIP_ID)
 		return true;
-	if (chipid == BCM4319_CHIP_ID)
-		return true;
 	return false;
 }
 
@@ -5461,22 +5456,12 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
 
 	/* Check the Device ID and make sure it's one that we support */
 	switch (devid) {
-	case BCM4325_D11DUAL_ID:	/* 4325 802.11a/g id */
-	case BCM4325_D11G_ID:	/* 4325 802.11g 2.4Ghz band id */
-	case BCM4325_D11A_ID:	/* 4325 802.11a 5Ghz band id */
-		BRCMF_INFO(("%s: found 4325 Dongle\n", __func__));
-		break;
 	case BCM4329_D11NDUAL_ID:	/* 4329 802.11n dualband device */
 	case BCM4329_D11N2G_ID:	/* 4329 802.11n 2.4G device */
 	case BCM4329_D11N5G_ID:	/* 4329 802.11n 5G device */
 	case 0x4329:
 		BRCMF_INFO(("%s: found 4329 Dongle\n", __func__));
 		break;
-	case BCM4319_D11N_ID:	/* 4319 802.11n id */
-	case BCM4319_D11N2G_ID:	/* 4319 802.11n2g id */
-	case BCM4319_D11N5G_ID:	/* 4319 802.11n5g id */
-		BRCMF_INFO(("%s: found 4319 Dongle\n", __func__));
-		break;
 	case 0:
 		BRCMF_INFO(("%s: allow device id 0, will check chip"
 			    " internals\n", __func__));
Signature · 1 line
1.7.4.1
#21 lore raw

PATCH 15/19 staging: brcm80211: remove SDLX_MSG from brcmfmac

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Use unified debug macros in fullmac

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +3 -6
index 7b66787..0953160 100644
@@ -29,6 +29,7 @@
 #include <soc.h>
 #include "dhd.h"
 #include "dhd_bus.h"
+#include "dhd_dbg.h"
 #include "sdio_host.h"
 
 #define SDIOH_API_ACCESS_RETRY_LIMIT	2
@@ -55,9 +56,6 @@
 #define BRCMF_SD_INFO(x)
 #endif				/* BCMDBG */
 
-/* debugging macros */
-#define SDLX_MSG(x)
-
 #define SDIOH_CMD_TYPE_NORMAL   0	/* Normal command */
 #define SDIOH_CMD_TYPE_APPEND   1	/* Append command */
 #define SDIOH_CMD_TYPE_CUTTHRU  2	/* Cut-through command */
@@ -486,7 +484,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 
 	card = brcmf_sdcard_attach((void *)0, &regs);
 	if (!card) {
-		SDLX_MSG(("%s: attach failed\n", __func__));
+		BRCMF_ERROR(("%s: attach failed\n", __func__));
 		goto err;
 	}
 	sdiodev->card = card;
@@ -498,7 +496,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 	sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF),
 				  0, 0, 0, 0, regs, card);
 	if (!sdiodev->bus) {
-		SDLX_MSG(("%s: device attach failed\n", __func__));
+		BRCMF_ERROR(("%s: device attach failed\n", __func__));
 		goto err;
 	}
 
@@ -525,7 +523,6 @@ int brcmf_sdio_register(struct brcmf_sdioh_driver *driver)
 {
 	drvinfo = *driver;
 
-	SDLX_MSG(("Linux Kernel SDIO/MMC Driver\n"));
 	return brcmf_sdio_function_init();
 }
 
Signature · 1 line
1.7.4.1
#23 lore raw

PATCH 17/19 staging: brcm80211: absorb brcmf_sdcard_attach into brcmf_sdio_probe

In reply to Arend van Spriel

From: Franky Lin <[email protected]>

Increase readability of brcmfmac

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c    |   68 +++++++++--------------
 drivers/staging/brcm80211/brcmfmac/sdio_host.h |   11 ----
 2 files changed, 27 insertions(+), 52 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +27 -41
index 53dfecd..6f88bd2 100644
@@ -57,32 +57,6 @@ static struct brcmf_sdioh_driver drvinfo = { NULL, NULL };
 
 module_param(sd_f2_blocksize, int, 0);
 
-struct brcmf_sdio_card*
-brcmf_sdcard_attach(void *cfghdl, u32 *regsva)
-{
-	struct brcmf_sdio_card *card;
-
-	card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC);
-	if (card == NULL) {
-		BRCMF_ERROR(("sdcard_attach: out of memory"));
-		return NULL;
-	}
-
-	card->sdioh = brcmf_sdioh_attach(cfghdl);
-	if (!card->sdioh) {
-		brcmf_sdcard_detach(card);
-		return NULL;
-	}
-
-	card->init_success = true;
-
-	*regsva = SI_ENUM_BASE;
-
-	/* Report the BAR, to fix if needed */
-	card->sbwad = SI_ENUM_BASE;
-	return card;
-}
-
 int brcmf_sdcard_detach(struct brcmf_sdio_card *card)
 {
 	if (card != NULL) {
@@ -455,35 +429,47 @@ u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card)
 int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 {
 	u32 regs = 0;
-	struct brcmf_sdio_card *card = NULL;
 	u32 vendevid;
+	int ret = 0;
+
+	sdiodev->card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC);
+	if (sdiodev->card == NULL) {
+		BRCMF_ERROR(("sdcard_attach: out of memory"));
+		ret = -ENOMEM;
+		goto out;
+	}
 
-	card = brcmf_sdcard_attach((void *)0, &regs);
-	if (!card) {
-		BRCMF_ERROR(("%s: attach failed\n", __func__));
-		goto err;
+	sdiodev->card->sdioh = brcmf_sdioh_attach((void *)0);
+	if (!sdiodev->card->sdioh) {
+		brcmf_sdcard_detach(sdiodev->card);
+		ret = -ENODEV;
+		goto out;
 	}
-	sdiodev->card = card;
+
+	sdiodev->card->init_success = true;
+
+	regs = SI_ENUM_BASE;
+
+	/* Report the BAR, to fix if needed */
+	sdiodev->card->sbwad = SI_ENUM_BASE;
 
 	/* Read the vendor/device ID from the CIS */
-	vendevid = brcmf_sdcard_query_device(card);
+	vendevid = brcmf_sdcard_query_device(sdiodev->card);
 
 	/* try to attach to the target device */
 	sdiodev->bus = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF),
-				  0, 0, 0, 0, regs, card);
+				  0, 0, 0, 0, regs, sdiodev->card);
 	if (!sdiodev->bus) {
 		BRCMF_ERROR(("%s: device attach failed\n", __func__));
-		goto err;
+		ret = -ENODEV;
+		goto out;
 	}
 
-	return 0;
-
-	/* error handling */
-err:
-	if (sdiodev->card)
+out:
+	if ((ret) && (sdiodev->card))
 		brcmf_sdcard_detach(sdiodev->card);
 
-	return -ENODEV;
+	return ret;
 }
 EXPORT_SYMBOL(brcmf_sdio_probe);
 
drivers/staging/brcm80211/brcmfmac/sdio_host.h +0 -11
index 5e7552e..68b6843 100644
@@ -136,17 +136,6 @@ struct brcmf_sdio_dev {
 	void *bus;
 };
 
-/* Attach and build an interface to the underlying SD host driver.
- *  - Allocates resources (structs, arrays, mem, OS handles, etc) needed by
- *    brcmf_sdcard.
- *  - Returns the sdio card handle and virtual address base for register access.
- *    The returned handle should be used in all subsequent calls, but the bcmsh
- *    implementation may maintain a single "default" handle (e.g. the first or
- *    most recent one) to enable single-instance implementations to pass NULL.
- */
-extern struct brcmf_sdio_card*
-brcmf_sdcard_attach(void *cfghdl, u32 *regsva);
-
 /* Detach - freeup resources allocated in attach */
 extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card);
 
Signature · 1 line
1.7.4.1
#25 lore raw

PATCH 19/19 staging: brcm80211: replace simple_strtoul usage in brcmfmac

In reply to Arend van Spriel

The usage of simple_strtoul is not preferred. Instead kstrtoul should be used. This patch fixes this for the brcmfmac driver.

---
 drivers/staging/brcm80211/brcmfmac/dhd_common.c |   27 +++++++++++++++++-----
 1 files changed, 21 insertions(+), 6 deletions(-)
drivers/staging/brcm80211/brcmfmac/dhd_common.c +21 -6
index 12c772d..fdd3629 100644
@@ -827,10 +827,13 @@ static int brcmf_c_pattern_atoh(char *src, char *dst)
 		return -EINVAL;
 	}
 	for (i = 0; *src != '\0'; i++) {
+		unsigned long res;
 		char num[3];
 		strncpy(num, src, 2);
 		num[2] = '\0';
-		dst[i] = (u8) simple_strtoul(num, NULL, 16);
+		if (kstrtoul(num, 16, &res))
+			return -EINVAL;
+		dst[i] = (u8)res;
 		src += 2;
 	}
 	return i;
@@ -840,6 +843,7 @@ void
 brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable,
 			     int master_mode)
 {
+	unsigned long res;
 	char *argv[8];
 	int i = 0;
 	const char *str;
@@ -876,7 +880,9 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable,
 	pkt_filterp = (struct brcmf_pkt_filter_enable *) (buf + str_len + 1);
 
 	/* Parse packet filter id. */
-	enable_parm.id = simple_strtoul(argv[i], NULL, 0);
+	enable_parm.id = 0;
+	if (!kstrtoul(argv[i], 0, &res))
+		enable_parm.id = (u32)res;
 
 	/* Parse enable/disable value. */
 	enable_parm.enable = enable;
@@ -913,6 +919,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
 	const char *str;
 	struct brcmf_pkt_filter pkt_filter;
 	struct brcmf_pkt_filter *pkt_filterp;
+	unsigned long res;
 	int buf_len;
 	int str_len;
 	int rc;
@@ -956,7 +963,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
 	pkt_filterp = (struct brcmf_pkt_filter *) (buf + str_len + 1);
 
 	/* Parse packet filter id. */
-	pkt_filter.id = simple_strtoul(argv[i], NULL, 0);
+	pkt_filter.id = 0;
+	if (!kstrtoul(argv[i], 0, &res))
+		pkt_filter.id = (u32)res;
 
 	if (NULL == argv[++i]) {
 		BRCMF_ERROR(("Polarity not provided\n"));
@@ -964,7 +973,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
 	}
 
 	/* Parse filter polarity. */
-	pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0);
+	pkt_filter.negate_match = 0;
+	if (!kstrtoul(argv[i], 0, &res))
+		pkt_filter.negate_match = (u32)res;
 
 	if (NULL == argv[++i]) {
 		BRCMF_ERROR(("Filter type not provided\n"));
@@ -972,7 +983,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
 	}
 
 	/* Parse filter type. */
-	pkt_filter.type = simple_strtoul(argv[i], NULL, 0);
+	pkt_filter.type = 0;
+	if (!kstrtoul(argv[i], 0, &res))
+		pkt_filter.type = (u32)res;
 
 	if (NULL == argv[++i]) {
 		BRCMF_ERROR(("Offset not provided\n"));
@@ -980,7 +993,9 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
 	}
 
 	/* Parse pattern filter offset. */
-	pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0);
+	pkt_filter.u.pattern.offset = 0;
+	if (!kstrtoul(argv[i], 0, &res))
+		pkt_filter.u.pattern.offset = (u32)res;
 
 	if (NULL == argv[++i]) {
 		BRCMF_ERROR(("Bitmask not provided\n"));
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/19 staging: brcm80211: fix for checkpatch warnings in phy directory

In reply to Arend van Spriel

From: Roland Vossen <[email protected]>

Most of them being 'line exceeds 80 chars'. Still checkpatch warnings for the phy dir left, these will be resolved in the subsequent commits.

---
 drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c   |  237 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h   |   51 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_int.h   |  138 +-
 drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c   |  407 ++-
 drivers/staging/brcm80211/brcmsmac/phy/phy_n.c     | 3687 +++++++++++---------
 drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c |  136 +-
 .../staging/brcm80211/brcmsmac/phy/phytbl_lcn.c    | 1168 +++----
 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c  |    3 +-
 drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h  |   24 +-
 9 files changed, 2897 insertions(+), 2954 deletions(-)
drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c +118 -119
index 2636114..582df4a 100644
@@ -119,7 +119,7 @@ const u8 ofdm_rate_lookup[] = {
 	BRCM_RATE_9M
 };
 
-#define PHY_WREG_LIMIT	24
+#define PHY_WREG_LIMIT  24
 
 static void wlc_set_phy_uninitted(struct brcms_phy *pi);
 static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi);
@@ -142,7 +142,7 @@ static void wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi,
 static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi);
 
 static s8 wlc_user_txpwr_antport_to_rfport(struct brcms_phy *pi, uint chan,
-					     u32 band, u8 rate);
+					   u32 band, u8 rate);
 static void wlc_phy_upd_env_txpwr_rate_limits(struct brcms_phy *pi, u32 band);
 static s8 wlc_phy_env_measure_vbat(struct brcms_phy *pi);
 static s8 wlc_phy_env_measure_temperature(struct brcms_phy *pi);
@@ -581,11 +581,11 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype,
 
 	idcode = wlc_phy_get_radio_ver(pi);
 	pi->pubpi.radioid =
-	    (idcode & IDCODE_ID_MASK) >> IDCODE_ID_SHIFT;
+		(idcode & IDCODE_ID_MASK) >> IDCODE_ID_SHIFT;
 	pi->pubpi.radiorev =
-	    (idcode & IDCODE_REV_MASK) >> IDCODE_REV_SHIFT;
+		(idcode & IDCODE_REV_MASK) >> IDCODE_REV_SHIFT;
 	pi->pubpi.radiover =
-	    (idcode & IDCODE_VER_MASK) >> IDCODE_VER_SHIFT;
+		(idcode & IDCODE_VER_MASK) >> IDCODE_VER_SHIFT;
 	if (!VALID_RADIO(pi, pi->pubpi.radioid))
 		goto err;
 
@@ -595,7 +595,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype,
 
 	pi->bw = WL_CHANSPEC_BW_20;
 	pi->radio_chanspec =
-	    BAND_2G(bandtype) ? CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36);
+		BAND_2G(bandtype) ? CH20MHZ_CHSPEC(1) : CH20MHZ_CHSPEC(36);
 
 	pi->rxiq_samps = PHY_NOISE_SAMPLE_LOG_NUM_NPHY;
 	pi->rxiq_antsel = ANT_RX_DIV_DEF;
@@ -617,7 +617,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype,
 
 	pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP;
 	pi->phy_txcore_enable_temp =
-	    PHY_CHAIN_TX_DISABLE_TEMP - PHY_HYSTERESIS_DELTATEMP;
+		PHY_CHAIN_TX_DISABLE_TEMP - PHY_HYSTERESIS_DELTATEMP;
 	pi->phy_tempsense_offset = 0;
 	pi->phy_txcore_heatedup = false;
 
@@ -640,8 +640,8 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype,
 	if (ISNPHY(pi)) {
 
 		pi->phycal_timer = wlapi_init_timer(pi->sh->physhim,
-							  wlc_phy_timercb_phycal,
-							  pi, "phycal");
+						    wlc_phy_timercb_phycal,
+						    pi, "phycal");
 		if (!pi->phycal_timer)
 			goto err;
 
@@ -664,7 +664,7 @@ wlc_phy_attach(struct shared_phy *sh, void *regs, int bandtype,
 
 	return &pi->pubpi_ro;
 
- err:
+err:
 	kfree(pi);
 	return NULL;
 }
@@ -688,7 +688,7 @@ void wlc_phy_detach(struct brcms_phy_pub *pih)
 			pi->sh->phy_head->next = NULL;
 
 		if (pi->pi_fptr.detach)
-			(pi->pi_fptr.detach) (pi);
+			(pi->pi_fptr.detach)(pi);
 
 		kfree(pi);
 	}
@@ -853,7 +853,7 @@ void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate)
 void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec)
 {
 	u32 mc;
-	void (*phy_init) (struct brcms_phy *) = NULL;
+	void (*phy_init)(struct brcms_phy *) = NULL;
 	struct brcms_phy *pi = (struct brcms_phy *) pih;
 
 	if (pi->init_in_progress)
@@ -889,7 +889,7 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec)
 
 	wlc_phy_switch_radio((struct brcms_phy_pub *) pi, ON);
 
-	(*phy_init) (pi);
+	(*phy_init)(pi);
 
 	pi->phy_init_por = false;
 
@@ -916,7 +916,7 @@ void wlc_phy_cal_init(struct brcms_phy_pub *pih)
 	if (!pi->initialized) {
 		cal_init = pi->pi_fptr.calinit;
 		if (cal_init)
-			(*cal_init) (pi);
+			(*cal_init)(pi);
 
 		pi->initialized = true;
 	}
@@ -1108,7 +1108,7 @@ wlc_phy_init_radio_regs(struct brcms_phy *pi, struct radio_regs *radioregs,
 
 void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on)
 {
-#define	DUMMY_PKT_LEN	20
+#define DUMMY_PKT_LEN   20
 	struct d11regs *regs = pi->regs;
 	int i, count;
 	u8 ofdmpkt[DUMMY_PKT_LEN] = {
@@ -1300,7 +1300,7 @@ void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec)
 {
 	struct brcms_phy *pi = (struct brcms_phy *) ppi;
 	u16 m_cur_channel;
-	void (*chanspec_set) (struct brcms_phy *, u16) = NULL;
+	void (*chanspec_set)(struct brcms_phy *, u16) = NULL;
 	m_cur_channel = CHSPEC_CHANNEL(chanspec);
 	if (CHSPEC_IS5G(chanspec))
 		m_cur_channel |= D11_CURCHANNEL_5G;
@@ -1310,7 +1310,7 @@ void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec)
 
 	chanspec_set = pi->pi_fptr.chanset;
 	if (chanspec_set)
-		(*chanspec_set) (pi, chanspec);
+		(*chanspec_set)(pi, chanspec);
 
 }
 
@@ -1409,9 +1409,8 @@ u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band)
 				continue;
 
 			channel = UPPER_20_SB(channel);
-			chspec =
-			    channel | WL_CHANSPEC_BW_40 |
-			    WL_CHANSPEC_CTL_SB_LOWER;
+			chspec =  channel | WL_CHANSPEC_BW_40 |
+				  WL_CHANSPEC_CTL_SB_LOWER;
 			if (band == BRCM_BAND_2G)
 				chspec |= WL_CHANSPEC_BAND_2G;
 			else
@@ -1508,10 +1507,8 @@ int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override)
 		if (!SCAN_INPROG_PHY(pi)) {
 			bool suspend;
 
-			suspend =
-			    (0 ==
-			     (R_REG(&pi->regs->maccontrol) &
-			      MCTL_EN_MAC));
+			suspend = (0 == (R_REG(&pi->regs->maccontrol) &
+					 MCTL_EN_MAC));
 
 			if (!suspend)
 				wlapi_suspend_mac_and_wait(pi->sh->physhim);
@@ -1588,7 +1585,8 @@ wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan,
 	pactrl = 0;
 
 	max_num_rate = ISNPHY(pi) ? TXP_NUM_RATES :
-	    ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 + 1) : (TXP_LAST_OFDM + 1);
+		       ISLCNPHY(pi) ? (TXP_LAST_SISO_MCS_20 +
+				       1) : (TXP_LAST_OFDM + 1);
 
 	for (rate = 0; rate < max_num_rate; rate++) {
 
@@ -1658,8 +1656,8 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 			for (i = TXP_FIRST_SISO_MCS_20;
 			     i <= TXP_LAST_SISO_MCS_20; i++) {
 				pi->tx_srom_max_rate_2g[i - 8] =
-				    pi->tx_srom_max_2g -
-				    ((offset_mcs & 0xf) * 2);
+					pi->tx_srom_max_2g -
+					((offset_mcs & 0xf) * 2);
 				offset_mcs >>= 4;
 			}
 		} else {
@@ -1667,8 +1665,8 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 			for (i = TXP_FIRST_SISO_MCS_20;
 			     i <= TXP_LAST_SISO_MCS_20; i++) {
 				pi->tx_srom_max_rate_2g[i - 8] =
-				    pi->tx_srom_max_2g -
-				    ((offset_mcs & 0xf) * 2);
+					pi->tx_srom_max_2g -
+					((offset_mcs & 0xf) * 2);
 				offset_mcs >>= 4;
 			}
 		}
@@ -1689,8 +1687,10 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 
 		if (pi->user_txpwr_at_rfport)
 			tx_pwr_target[rate] +=
-			    wlc_user_txpwr_antport_to_rfport(pi, target_chan,
-							     band, rate);
+				wlc_user_txpwr_antport_to_rfport(pi,
+								 target_chan,
+								 band,
+								 rate);
 
 		{
 
@@ -1701,7 +1701,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 			maxtxpwr = min(maxtxpwr, pi->txpwr_limit[rate]);
 
 			maxtxpwr =
-			    (maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0;
+				(maxtxpwr > pactrl) ? (maxtxpwr - pactrl) : 0;
 
 			maxtxpwr = (maxtxpwr > 6) ? (maxtxpwr - 6) : 0;
 
@@ -1714,7 +1714,7 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 		}
 
 		tx_pwr_target[rate] =
-		    min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]);
+			min(tx_pwr_target[rate], pi->txpwr_env_limit[rate]);
 
 		if (tx_pwr_target[rate] > tx_pwr_max)
 			tx_pwr_max_rate_ind = rate;
@@ -1733,15 +1733,15 @@ void wlc_phy_txpower_recalc_target(struct brcms_phy *pi)
 
 		if (!pi->hwpwrctrl || ISNPHY(pi))
 			pi->tx_power_offset[rate] =
-			    pi->tx_power_max - pi->tx_power_target[rate];
+				pi->tx_power_max - pi->tx_power_target[rate];
 		else
 			pi->tx_power_offset[rate] =
-			    pi->tx_power_target[rate] - pi->tx_power_min;
+				pi->tx_power_target[rate] - pi->tx_power_min;
 	}
 
 	txpwr_recalc_fn = pi->pi_fptr.txpwrrecalc;
 	if (txpwr_recalc_fn)
-		(*txpwr_recalc_fn) (pi);
+		(*txpwr_recalc_fn)(pi);
 }
 
 void
@@ -1781,7 +1781,7 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr,
 				txpwr_ptr1 = txpwr->mcs_40_siso;
 				txpwr_ptr2 = txpwr->ofdm_40_siso;
 				rate_start_index =
-				    WL_TX_POWER_OFDM40_SISO_FIRST;
+					WL_TX_POWER_OFDM40_SISO_FIRST;
 				break;
 			case 3:
 
@@ -1791,18 +1791,21 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr,
 				break;
 			}
 
-			for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; rate2++) {
+			for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM;
+			     rate2++) {
 				tmp_txpwr_limit[rate2] = 0;
 				tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] =
-				    txpwr_ptr1[rate2];
+					txpwr_ptr1[rate2];
 			}
-			wlc_phy_mcs_to_ofdm_powers_nphy(tmp_txpwr_limit, 0,
-				BRCMS_NUM_RATES_OFDM - 1, BRCMS_NUM_RATES_OFDM);
+			wlc_phy_mcs_to_ofdm_powers_nphy(
+				tmp_txpwr_limit, 0,
+				BRCMS_NUM_RATES_OFDM -
+				1, BRCMS_NUM_RATES_OFDM);
 			for (rate1 = rate_start_index, rate2 = 0;
 			     rate2 < BRCMS_NUM_RATES_OFDM; rate1++, rate2++)
 				pi->txpwr_limit[rate1] =
-				    min(txpwr_ptr2[rate2],
-					tmp_txpwr_limit[rate2]);
+					min(txpwr_ptr2[rate2],
+					    tmp_txpwr_limit[rate2]);
 		}
 
 		for (k = 0; k < 4; k++) {
@@ -1832,19 +1835,22 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr,
 				rate_start_index = WL_TX_POWER_MCS40_CDD_FIRST;
 				break;
 			}
-			for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM; rate2++) {
+			for (rate2 = 0; rate2 < BRCMS_NUM_RATES_OFDM;
+			     rate2++) {
 				tmp_txpwr_limit[rate2] = 0;
 				tmp_txpwr_limit[BRCMS_NUM_RATES_OFDM + rate2] =
-				    txpwr_ptr1[rate2];
+					txpwr_ptr1[rate2];
 			}
-			wlc_phy_ofdm_to_mcs_powers_nphy(tmp_txpwr_limit, 0,
-				BRCMS_NUM_RATES_OFDM - 1, BRCMS_NUM_RATES_OFDM);
+			wlc_phy_ofdm_to_mcs_powers_nphy(
+				tmp_txpwr_limit, 0,
+				BRCMS_NUM_RATES_OFDM -
+				1, BRCMS_NUM_RATES_OFDM);
 			for (rate1 = rate_start_index, rate2 = 0;
 			     rate2 < BRCMS_NUM_RATES_MCS_1_STREAM;
 			     rate1++, rate2++)
 				pi->txpwr_limit[rate1] =
-				    min(txpwr_ptr2[rate2],
-					tmp_txpwr_limit[rate2]);
+					min(txpwr_ptr2[rate2],
+					    tmp_txpwr_limit[rate2]);
 		}
 
 		for (k = 0; k < 2; k++) {
@@ -1888,10 +1894,10 @@ wlc_phy_txpower_reg_limit_calc(struct brcms_phy *pi, struct txpwr_limits *txpwr,
 		pi->txpwr_limit[WL_TX_POWER_MCS_32] = txpwr->mcs32;
 
 		pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST] =
-		    min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST],
-			pi->txpwr_limit[WL_TX_POWER_MCS_32]);
+			min(pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST],
+			    pi->txpwr_limit[WL_TX_POWER_MCS_32]);
 		pi->txpwr_limit[WL_TX_POWER_MCS_32] =
-		    pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST];
+			pi->txpwr_limit[WL_TX_POWER_MCS40_CDD_FIRST];
 	}
 }
 
@@ -2005,9 +2011,9 @@ void wlc_phy_txpower_update_shm(struct brcms_phy *pi)
 			const u8 ucode_ofdm_rates[] = {
 				0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c
 			};
-			offset = wlapi_bmac_rate_shm_offset(pi->sh->physhim,
-							    ucode_ofdm_rates[j -
-									     TXP_FIRST_OFDM]);
+			offset = wlapi_bmac_rate_shm_offset(
+				pi->sh->physhim,
+				ucode_ofdm_rates[j - TXP_FIRST_OFDM]);
 			wlapi_bmac_write_shm(pi->sh->physhim, offset + 6,
 					     pi->tx_power_offset[j]);
 			wlapi_bmac_write_shm(pi->sh->physhim, offset + 14,
@@ -2021,11 +2027,11 @@ void wlc_phy_txpower_update_shm(struct brcms_phy *pi)
 
 		for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++)
 			pi->tx_power_offset[i] =
-			    (u8) roundup(pi->tx_power_offset[i], 8);
+				(u8) roundup(pi->tx_power_offset[i], 8);
 		wlapi_bmac_write_shm(pi->sh->physhim, M_OFDM_OFFSET,
-				     (u16) ((pi->
-						tx_power_offset[TXP_FIRST_OFDM]
-						+ 7) >> 3));
+				     (u16)
+				     ((pi->tx_power_offset[TXP_FIRST_OFDM]
+				       + 7) >> 3));
 	}
 }
 
@@ -2052,9 +2058,7 @@ void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl)
 	pi->txpwrctrl = hwpwrctrl;
 
 	if (ISNPHY(pi)) {
-		suspend =
-		    (0 ==
-		     (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
+		suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
 		if (!suspend)
 			wlapi_suspend_mac_and_wait(pi->sh->physhim);
 
@@ -2092,38 +2096,31 @@ static u32 wlc_phy_txpower_est_power_nphy(struct brcms_phy *pi)
 	estPower1 = read_phy_reg(pi, 0x118);
 	estPower2 = read_phy_reg(pi, 0x119);
 
-	if ((estPower1 & (0x1 << 8))
-	    == (0x1 << 8))
-		pwr0 = (u8) (estPower1 & (0xff << 0))
-		    >> 0;
+	if ((estPower1 & (0x1 << 8)) == (0x1 << 8))
+		pwr0 = (u8) (estPower1 & (0xff << 0)) >> 0;
 	else
 		pwr0 = 0x80;
 
-	if ((estPower2 & (0x1 << 8))
-	    == (0x1 << 8))
-		pwr1 = (u8) (estPower2 & (0xff << 0))
-		    >> 0;
+	if ((estPower2 & (0x1 << 8)) == (0x1 << 8))
+		pwr1 = (u8) (estPower2 & (0xff << 0)) >> 0;
 	else
 		pwr1 = 0x80;
 
 	tx0_status = read_phy_reg(pi, 0x1ed);
 	tx1_status = read_phy_reg(pi, 0x1ee);
 
-	if ((tx0_status & (0x1 << 15))
-	    == (0x1 << 15))
-		adj_pwr0 = (u8) (tx0_status & (0xff << 0))
-		    >> 0;
+	if ((tx0_status & (0x1 << 15)) == (0x1 << 15))
+		adj_pwr0 = (u8) (tx0_status & (0xff << 0)) >> 0;
 	else
 		adj_pwr0 = 0x80;
-	if ((tx1_status & (0x1 << 15))
-	    == (0x1 << 15))
-		adj_pwr1 = (u8) (tx1_status & (0xff << 0))
-		    >> 0;
+	if ((tx1_status & (0x1 << 15)) == (0x1 << 15))
+		adj_pwr1 = (u8) (tx1_status & (0xff << 0)) >> 0;
 	else
 		adj_pwr1 = 0x80;
 
-	est_pwr =
-	    (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) | adj_pwr1);
+	est_pwr = (u32) ((pwr0 << 24) | (pwr1 << 16) | (adj_pwr0 << 8) |
+			 adj_pwr1);
+
 	return est_pwr;
 }
 
@@ -2144,7 +2141,7 @@ wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power,
 		power->flags |= (WL_TX_POWER_F_MIMO);
 		if (pi->nphy_txpwrctrl == PHY_TPC_HW_ON)
 			power->flags |=
-			    (WL_TX_POWER_F_ENABLED | WL_TX_POWER_F_HW);
+				(WL_TX_POWER_F_ENABLED | WL_TX_POWER_F_HW);
 	} else if (ISLCNPHY(pi)) {
 		power->rf_cores = 1;
 		power->flags |= (WL_TX_POWER_F_SISO);
@@ -2207,16 +2204,18 @@ wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power,
 			power->tx_power_max[1] = pi->tx_power_max;
 
 			power->tx_power_max_rate_ind[0] =
-			    pi->tx_power_max_rate_ind;
+				pi->tx_power_max_rate_ind;
 			power->tx_power_max_rate_ind[1] =
-			    pi->tx_power_max_rate_ind;
+				pi->tx_power_max_rate_ind;
 
 			if (wlc_phy_tpc_isenabled_lcnphy(pi))
 				power->flags |=
-				    (WL_TX_POWER_F_HW | WL_TX_POWER_F_ENABLED);
+					(WL_TX_POWER_F_HW |
+					 WL_TX_POWER_F_ENABLED);
 			else
 				power->flags &=
-				    ~(WL_TX_POWER_F_HW | WL_TX_POWER_F_ENABLED);
+					~(WL_TX_POWER_F_HW |
+					  WL_TX_POWER_F_ENABLED);
 
 			wlc_lcnphy_get_tssi(pi, (s8 *) &power->est_Pout[0],
 					    (s8 *) &power->est_Pout_cck);
@@ -2261,8 +2260,7 @@ void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val)
 	if (!pi->sh->clk)
 		return;
 
-	suspend =
-	    (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
+	suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
 	if (!suspend)
 		wlapi_suspend_mac_and_wait(pi->sh->physhim);
 
@@ -2306,7 +2304,7 @@ wlc_phy_noise_calc_phy(struct brcms_phy *pi, u32 *cmplx_pwr, s8 *pwr_ant)
 		pwr_ant[i] = cmplx_pwr_dbm[i];
 	}
 	pi->nphy_noise_index =
-	    MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ);
+		MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ);
 	return true;
 }
 
@@ -2343,12 +2341,11 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch)
 	if (pi->phy_fixed_noise) {
 		if (ISNPHY(pi)) {
 			pi->nphy_noise_win[WL_ANT_IDX_1][pi->nphy_noise_index] =
-			    PHY_NOISE_FIXED_VAL_NPHY;
+				PHY_NOISE_FIXED_VAL_NPHY;
 			pi->nphy_noise_win[WL_ANT_IDX_2][pi->nphy_noise_index] =
-			    PHY_NOISE_FIXED_VAL_NPHY;
+				PHY_NOISE_FIXED_VAL_NPHY;
 			pi->nphy_noise_index = MODINC_POW2(pi->nphy_noise_index,
 							   PHY_NOISE_WINDOW_SZ);
-
 			noise_dbm = PHY_NOISE_FIXED_VAL_NPHY;
 		} else {
 			noise_dbm = PHY_NOISE_FIXED_VAL;
@@ -2413,15 +2410,14 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch)
 			wlapi_enable_mac(pi->sh->physhim);
 
 			for (i = 0; i < pi->pubpi.phy_corenum; i++)
-				cmplx_pwr[i] =
-				    (est[i].i_pwr +
-				     est[i].q_pwr) >> log_num_samps;
+				cmplx_pwr[i] = (est[i].i_pwr + est[i].q_pwr) >>
+					       log_num_samps;
 
 			wlc_phy_noise_calc_phy(pi, cmplx_pwr, noise_dbm_ant);
 
 			for (i = 0; i < pi->pubpi.phy_corenum; i++) {
 				pi->nphy_noise_win[i][pi->nphy_noise_index] =
-				    noise_dbm_ant[i];
+					noise_dbm_ant[i];
 
 				if (noise_dbm_ant[i] > noise_dbm)
 					noise_dbm = noise_dbm_ant[i];
@@ -2433,7 +2429,7 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch)
 		}
 	}
 
- done:
+done:
 
 	if (!wait_for_intr)
 		wlc_phy_noise_cb(pi, ch, noise_dbm);
@@ -2457,9 +2453,9 @@ static void wlc_phy_noise_cb(struct brcms_phy *pi, u8 channel, s8 noise_dbm)
 	if (pi->phynoise_state & PHY_NOISE_STATE_MON) {
 		if (pi->phynoise_chan_watchdog == channel) {
 			pi->sh->phy_noise_window[pi->sh->phy_noise_index] =
-			    noise_dbm;
+				noise_dbm;
 			pi->sh->phy_noise_index =
-			    MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ);
+				MODINC(pi->sh->phy_noise_index, MA_WINDOW_SZ);
 		}
 		pi->phynoise_state &= ~PHY_NOISE_STATE_MON;
 	}
@@ -2481,7 +2477,8 @@ static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi)
 	memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr));
 	memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant));
 
-	for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2, core++) {
+	for (idx = 0, core = 0; core < pi->pubpi.phy_corenum; idx += 2,
+	     core++) {
 		lo = wlapi_bmac_read_shm(pi->sh->physhim, M_PWRIND_MAP(idx));
 		hi = wlapi_bmac_read_shm(pi->sh->physhim,
 					 M_PWRIND_MAP(idx + 1));
@@ -2498,13 +2495,13 @@ static s8 wlc_phy_noise_read_shmem(struct brcms_phy *pi)
 
 	for (core = 0; core < pi->pubpi.phy_corenum; core++) {
 		pi->nphy_noise_win[core][pi->nphy_noise_index] =
-		    noise_dbm_ant[core];
+			noise_dbm_ant[core];
 
 		if (noise_dbm_ant[core] > noise_dbm)
 			noise_dbm = noise_dbm_ant[core];
 	}
 	pi->nphy_noise_index =
-	    MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ);
+		MODINC_POW2(pi->nphy_noise_index, PHY_NOISE_WINDOW_SZ);
 
 	return noise_dbm;
 
@@ -2665,7 +2662,7 @@ void wlc_phy_rssi_compute(struct brcms_phy_pub *pih, void *ctx)
 		rssi = wlc_phy_rssi_compute_nphy(pi, wlc_rxhdr);
 	}
 
- end:
+end:
 	wlc_rxhdr->rssi = (s8) rssi;
 }
 
@@ -2739,8 +2736,9 @@ void wlc_phy_watchdog(struct brcms_phy_pub *pih)
 		    ((pi->sh->now - pi->phy_lastcal) >=
 		     pi->sh->glacial_timer)) {
 			if (!(SCAN_RM_IN_PROGRESS(pi) || ASSOC_INPROG_PHY(pi)))
-				wlc_lcnphy_calib_modes(pi,
-						       LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL);
+				wlc_lcnphy_calib_modes(
+					pi,
+					LCNPHY_PERICAL_TEMPBASED_TXPWRCTRL);
 			if (!
 			    (SCAN_RM_IN_PROGRESS(pi) || PLT_INPROG_PHY(pi)
 			     || ASSOC_INPROG_PHY(pi)
@@ -2763,7 +2761,7 @@ void wlc_phy_BSSinit(struct brcms_phy_pub *pih, bool bonlyap, int rssi)
 	if (ISLCNPHY(pi)) {
 		for (i = 0; i < MA_WINDOW_SZ; i++)
 			pi->sh->phy_noise_window[i] =
-			    PHY_NOISE_FIXED_VAL_LCNPHY;
+				PHY_NOISE_FIXED_VAL_LCNPHY;
 	}
 	pi->sh->phy_noise_index = 0;
 
@@ -2819,9 +2817,8 @@ void wlc_phy_cordic(s32 theta, struct cs32 *val)
 	angle = 0;
 
 	signtheta = (theta < 0) ? -1 : 1;
-	theta =
-	    ((theta + FIXED(180) * signtheta) % FIXED(360)) -
-	    FIXED(180) * signtheta;
+	theta =	((theta + FIXED(180) * signtheta) % FIXED(360)) -
+		FIXED(180) * signtheta;
 
 	if (FLOAT(theta) > 90) {
 		theta -= FIXED(180);
@@ -2895,8 +2892,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason)
 			if (PHY_PERICAL_MPHASE_PENDING(pi))
 				wlc_phy_cal_perical_mphase_reset(pi);
 
-			wlc_phy_cal_perical_mphase_schedule(pi,
-							    PHY_PERICAL_INIT_DELAY);
+			wlc_phy_cal_perical_mphase_schedule(
+				pi,
+				PHY_PERICAL_INIT_DELAY);
 		}
 		break;
 
@@ -2921,9 +2919,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason)
 		if (pi->phycal_tempdelta) {
 			nphy_currtemp = wlc_phy_tempsense_nphy(pi);
 			delta_temp =
-			    (nphy_currtemp > pi->nphy_lastcal_temp) ?
-			    nphy_currtemp - pi->nphy_lastcal_temp :
-			    pi->nphy_lastcal_temp - nphy_currtemp;
+				(nphy_currtemp > pi->nphy_lastcal_temp) ?
+				nphy_currtemp - pi->nphy_lastcal_temp :
+				pi->nphy_lastcal_temp - nphy_currtemp;
 
 			if ((delta_temp < (s16) pi->phycal_tempdelta) &&
 			    (pi->nphy_txiqlocal_chanspec ==
@@ -2936,8 +2934,9 @@ void wlc_phy_cal_perical(struct brcms_phy_pub *pih, u8 reason)
 		if (do_periodic_cal) {
 			if (pi->nphy_perical == PHY_PERICAL_MPHASE) {
 				if (!PHY_PERICAL_MPHASE_PENDING(pi))
-					wlc_phy_cal_perical_mphase_schedule(pi,
-									    PHY_PERICAL_WDOG_DELAY);
+					wlc_phy_cal_perical_mphase_schedule(
+						pi,
+						PHY_PERICAL_WDOG_DELAY);
 			} else if (pi->nphy_perical == PHY_PERICAL_SPHASE)
 				wlc_phy_cal_perical_nphy_run(pi,
 							     PHY_PERICAL_AUTO);
@@ -3035,11 +3034,11 @@ s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec)
 	u8 siso_mcs_id, cdd_mcs_id;
 
 	siso_mcs_id =
-	    (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_SISO :
-	    TXP_FIRST_MCS_20_SISO;
+		(CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_SISO :
+		TXP_FIRST_MCS_20_SISO;
 	cdd_mcs_id =
-	    (CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_CDD :
-	    TXP_FIRST_MCS_20_CDD;
+		(CHSPEC_IS40(chanspec)) ? TXP_FIRST_MCS_40_CDD :
+		TXP_FIRST_MCS_20_CDD;
 
 	if (pi->tx_power_target[siso_mcs_id] >
 	    (pi->tx_power_target[cdd_mcs_id] + 12))
drivers/staging/brcm80211/brcmsmac/phy/phy_hal.h +28 -23

76 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phy_int.h +85 -53

211 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c +220 -187

924 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phy_n.c +1960 -1727

1,200 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phy_qmath.c +75 -61

136 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phytbl_lcn.c +392 -776

1,168 lines not on this page · raw message

drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.c +2 -1
index 7f741f4..d1455ae 100644

Lines of this file are not shown. View the raw message.

drivers/staging/brcm80211/brcmsmac/phy/phytbl_n.h +17 -7
index c5266cf..dc8a84e 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4.1

Part of the diff is not shown here. View the raw message.

#13 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

In reply to Arend van Spriel

drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c static int brcmf_ops_sdio_probe(struct sdio_func *func, · line 1066

Quoted 10 lines · Arend van Spriel
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +0 -6
@@ -1058,12 +1028,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
 		sdio_func_0.num = 0;
 		sdio_func_0.card = func->card;
 		gInstance->func[0] = &sdio_func_0;
-		if (func->device == 0x4) {	/* 4318 */
-			gInstance->func[2] = NULL;
-			sd_trace(("NIC found, calling brcmf_sdio_probe...\n"));
-			ret = brcmf_sdio_probe(&sdmmc_dev);
-		}
-		atomic_set(&brcmf_mmc_suspend, false);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Did you intend to delete that?

Review static int brcmf_ops_sdio_probe(struct sdio_func *func, · line 1032

Quoted 2 lines
(quoted diff) +0 -0
 	}
 

regards,
dan carpenter

#14 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

Quoted 12 lines · Dan Carpenter

drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c static int brcmf_ops_sdio_probe(struct sdio_func *func, · line 1066

Quoted 10 lines · Arend van Spriel
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +0 -6
@@ -1058,12 +1028,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
  		sdio_func_0.num = 0;
  		sdio_func_0.card = func->card;
  		gInstance->func[0] =&sdio_func_0;
-		if (func->device == 0x4) {	/* 4318 */
-			gInstance->func[2] = NULL;
-			sd_trace(("NIC found, calling brcmf_sdio_probe...\n"));
-			ret = brcmf_sdio_probe(&sdmmc_dev);
-		}
-		atomic_set(&brcmf_mmc_suspend, false);
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 4 lines

Did you intend to delete that?

Quoted 2 lines
(quoted diff) +0 -0
  	}
 

Hi Dan

No, i didn't. Thank you for pointing out this. I missed it when I rebased my local branch. It didn't break any thing because brcmf_mmc_suspend is a global variable. Is it ok to keep the patch like this? I will prepare another patch to put it back and put the variable in a structure instead of using a global.

Thanks,
Franky

#15 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

Quoted 5 lines · Franky Lin

No, i didn't. Thank you for pointing out this. I missed it when I rebased my local branch. It didn't break any thing because brcmf_mmc_suspend is a global variable. Is it ok to keep the patch like this? I will prepare another patch to put it back and put the variable in a structure instead of using a global.

Broken commits are bad for bisecting. "git bisect" is used to search for a revision that introduces a bug. "git bisect" selects a commit between the known working and the known broken revision. If the commit selected by "git commit" suffers from additional breakage, this could lead to wasted time and possibly to a failure to find the commit responsible for the original problem.

Please don't submit known broken commits. You can always send another version of the series. If you are using stgit, see "stg mail --help".

Signature · 2 lines
Regards,
Pavel Roskin
#16 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

Quoted 15 lines · Pavel Roskin
Quoted 5 lines · Franky Lin

No, i didn't. Thank you for pointing out this. I missed it when I rebased my local branch. It didn't break any thing because brcmf_mmc_suspend is a global variable. Is it ok to keep the patch like this? I will prepare another patch to put it back and put the variable in a structure instead of using a global.

Broken commits are bad for bisecting. "git bisect" is used to search for a revision that introduces a bug. "git bisect" selects a commit between the known working and the known broken revision. If the commit selected by "git commit" suffers from additional breakage, this could lead to wasted time and possibly to a failure to find the commit responsible for the original problem.

Quoted 3 lines

Please don't submit known broken commits. You can always send another version of the series. If you are using stgit, see "stg mail --help".

Thanks Pavel. We will send out a v2 to fix this.

#17 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

In reply to Pavel Roskin
Quoted 8 lines · Pavel Roskin
Quoted 5 lines · Franky Lin

No, i didn't. Thank you for pointing out this. I missed it when I rebased my local branch. It didn't break any thing because brcmf_mmc_suspend is a global variable. Is it ok to keep the patch like this? I will prepare another patch to put it back and put the variable in a structure instead of using a global.

Quoted 7 lines

Broken commits are bad for bisecting. "git bisect" is used to search for a revision that introduces a bug. "git bisect" selects a commit between the known working and the known broken revision. If the commit selected by "git commit" suffers from additional breakage, this could lead to wasted time and possibly to a failure to find the commit responsible for the original problem.

This commit doesn't break anything. He explained that. brcmf_mmc_suspend is already initialized to false here because it is a static variable.

Don't send a v2 of the patchset.

regards,
dan carpenter

PS: Franky, if you already know the answer then you can just tell us. You don't need to ask for permission.

#18 lore raw

Re: [PATCH 12/19] staging: brcm80211: remove code for unsupported chip

Quoting Dan Carpenter <[email protected]>:

Quoted 3 lines

This commit doesn't break anything. He explained that. brcmf_mmc_suspend is already initialized to false here because it is a static variable.

Sorry, I misinterpreted "doesn't break anything" as "doesn't cause compiler errors or warnings".

Signature · 2 lines
Regards,
Pavel Roskin