Skip to contentSkip to conversation

staging: brcm80211: linus_osl.c cleanups

PATCH In review [email protected] 2 participants 9 messages Oct 12, 2010 – Oct 14, 2010 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: brcm80211: linus_osl.c cleanups

These patches replace part of proprietary utility functions with public kernel versions.

The following changes since commit 0f0881b09078fe3a6bc70f05e8ba49a52b2478a2:
Greg Kroah-Hartman (1):
Staging: brcm80211: remove TRUE #define

Mike Rapoport (7):
staging: brcm80211: remove OSL_DELAY
staging: brcm80211: remove DHD_USE_STATIC_BUF
staging: brcm80211: remove osl_malloced()/MALLOCED()
staging: brcm80211: replace MALLOC() with k[zm]alloc
staging: brcm80211: remove unused NATIVE_{MALLOC,MFREE}
staging: brcm80211: replace MFREE with kfree
staging: brcm80211: remove unrefrenced malloced field

 drivers/staging/brcm80211/brcmfmac/bcmsdh.c        |   16 +-
 drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c  |   20 +-
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c  |   27 +--
 .../brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c        |    4 +-
 drivers/staging/brcm80211/brcmfmac/dhd.h           |    6 +-
 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c       |   20 +--
 drivers/staging/brcm80211/brcmfmac/dhd_common.c    |   18 +-
 .../staging/brcm80211/brcmfmac/dhd_custom_gpio.c   |    2 +-
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |   53 ++----
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |   98 +++------
 drivers/staging/brcm80211/include/bcmutils.h       |    2 +-
 drivers/staging/brcm80211/include/linux_osl.h      |   18 --
 drivers/staging/brcm80211/phy/wlc_phy_cmn.c        |   20 +-
 drivers/staging/brcm80211/phy/wlc_phy_lcn.c        |   87 ++++----
 drivers/staging/brcm80211/phy/wlc_phy_n.c          |   88 ++++----
 drivers/staging/brcm80211/sys/wl_mac80211.c        |   33 ++--
 drivers/staging/brcm80211/sys/wlc_alloc.c          |   57 ++---
 drivers/staging/brcm80211/sys/wlc_ampdu.c          |   12 +-
 drivers/staging/brcm80211/sys/wlc_antsel.c         |    8 +-
 drivers/staging/brcm80211/sys/wlc_bmac.c           |   32 ++--
 drivers/staging/brcm80211/sys/wlc_channel.c        |    8 +-
 drivers/staging/brcm80211/sys/wlc_event.c          |   13 +-
 drivers/staging/brcm80211/sys/wlc_mac80211.c       |   19 +-
 drivers/staging/brcm80211/sys/wlc_phy_shim.c       |    8 +-
 drivers/staging/brcm80211/util/aiutils.c           |    8 +-
 drivers/staging/brcm80211/util/bcmotp.c            |    6 +-
 drivers/staging/brcm80211/util/bcmsrom.c           |   36 ++--
 drivers/staging/brcm80211/util/hnddma.c            |   43 ++---
 drivers/staging/brcm80211/util/hndpmu.c            |   14 +-
 drivers/staging/brcm80211/util/linux_osl.c         |  228 --------------------
 drivers/staging/brcm80211/util/nicpci.c            |   15 +-
 drivers/staging/brcm80211/util/nvram/nvram_ro.c    |    9 +-
 drivers/staging/brcm80211/util/sbutils.c           |   14 +-
 drivers/staging/brcm80211/util/siutils.c           |   21 +-
 34 files changed, 335 insertions(+), 728 deletions(-)
#1 lore raw

PATCH 1/7 staging: brcm80211: remove OSL_DELAY

and use udelay and mdelay instead

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c        |    4 +-
 drivers/staging/brcm80211/brcmfmac/dhd.h           |    2 +-
 .../staging/brcm80211/brcmfmac/dhd_custom_gpio.c   |    2 +-
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |    2 +-
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |    2 +-
 drivers/staging/brcm80211/include/bcmutils.h       |    2 +-
 drivers/staging/brcm80211/include/linux_osl.h      |    3 -
 drivers/staging/brcm80211/phy/wlc_phy_cmn.c        |    8 +-
 drivers/staging/brcm80211/phy/wlc_phy_lcn.c        |   64 ++++++++--------
 drivers/staging/brcm80211/phy/wlc_phy_n.c          |   76 ++++++++++----------
 drivers/staging/brcm80211/sys/wlc_ampdu.c          |    2 +-
 drivers/staging/brcm80211/sys/wlc_bmac.c           |   30 ++++----
 drivers/staging/brcm80211/util/aiutils.c           |    8 +-
 drivers/staging/brcm80211/util/bcmotp.c            |    2 +-
 drivers/staging/brcm80211/util/hnddma.c            |    8 +-
 drivers/staging/brcm80211/util/hndpmu.c            |   14 ++--
 drivers/staging/brcm80211/util/linux_osl.c         |   11 ---
 drivers/staging/brcm80211/util/nicpci.c            |    6 +-
 drivers/staging/brcm80211/util/sbutils.c           |   14 ++--
 drivers/staging/brcm80211/util/siutils.c           |   12 ++--
 20 files changed, 129 insertions(+), 143 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +2 -2
index 87b2585..42f1878 100644
@@ -198,7 +198,7 @@ u8 bcmsdh_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err)
 #ifdef SDIOH_API_ACCESS_RETRY_LIMIT
 	do {
 		if (retry)	/* wait for 1 ms till bus get settled down */
-			OSL_DELAY(1000);
+			udelay(1000);
 #endif
 		status =
 		    sdioh_cfg_read(bcmsdh->sdioh, fnc_num, addr,
@@ -233,7 +233,7 @@ bcmsdh_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err)
 #ifdef SDIOH_API_ACCESS_RETRY_LIMIT
 	do {
 		if (retry)	/* wait for 1 ms till bus get settled down */
-			OSL_DELAY(1000);
+			udelay(1000);
 #endif
 		status =
 		    sdioh_cfg_write(bcmsdh->sdioh, fnc_num, addr,
drivers/staging/brcm80211/brcmfmac/dhd.h +1 -1
index 6d0c0dd..8ec3ebd 100644
@@ -188,7 +188,7 @@ typedef struct dhd_pub {
 #define SPINWAIT_SLEEP(a, exp, us)  do { \
 		uint countdown = (us) + 9; \
 		while ((exp) && (countdown >= 10)) { \
-			OSL_DELAY(10);  \
+			udelay(10);  \
 			countdown -= 10;  \
 		} \
 	} while (0)
drivers/staging/brcm80211/brcmfmac/dhd_custom_gpio.c +1 -1
index 5a86f92..b200ee7 100644
@@ -132,7 +132,7 @@ void dhd_customer_gpio_wlan_ctrl(int onoff)
 		bcm_wlan_power_on(1);
 #endif				/* CUSTOMER_HW */
 		/* Lets customer power to get stable */
-		OSL_DELAY(200);
+		udelay(200);
 		break;
 	}
 }
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +1 -1
index 5c8224f..717e586 100644
@@ -614,7 +614,7 @@ int dhd_timeout_expired(dhd_timeout_t *tmo)
 	tmo->elapsed += tmo->increment;
 
 	if (tmo->increment < tmo->tick) {
-		OSL_DELAY(tmo->increment);
+		udelay(tmo->increment);
 		tmo->increment *= 2;
 		if (tmo->increment > tmo->tick)
 			tmo->increment = tmo->tick;
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +1 -1
index 40157a1..363db37 100644
@@ -5271,7 +5271,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva,
 		/* Now request ALP be put on the bus */
 		bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 				 DHD_INIT_CLKCTL2, &err);
-		OSL_DELAY(65);
+		udelay(65);
 
 		for (fn = 0; fn <= numfn; fn++) {
 			cis[fn] = MALLOC(osh, SBSDIO_CIS_SIZE_LIMIT);
drivers/staging/brcm80211/include/bcmutils.h +1 -1
index 5edb50d..4bff60e 100644
@@ -42,7 +42,7 @@
 #define SPINWAIT(exp, us) { \
 	uint countdown = (us) + 9; \
 	while ((exp) && (countdown >= 10)) {\
-		OSL_DELAY(10); \
+		udelay(10); \
 		countdown -= 10; \
 	} \
 }
drivers/staging/brcm80211/include/linux_osl.h +0 -3
index a8ccc74..12c9c32 100644
@@ -49,9 +49,6 @@ extern void osl_assert(char *exp, char *file, int line);
 #endif				/* __GNUC__ */
 #endif				/* defined(BCMDBG_ASSERT) */
 
-#define	OSL_DELAY(usec)		osl_delay(usec)
-extern void osl_delay(uint usec);
-
 /* PCI configuration space access macros */
 #define	OSL_PCI_READ_CONFIG(osh, offset, size) \
 	osl_pci_read_config((osh), (offset), (size))
drivers/staging/brcm80211/phy/wlc_phy_cmn.c +4 -4
index 2a8dada..5da1597 100644
@@ -201,7 +201,7 @@ void wlc_radioreg_enter(wlc_phy_t *pih)
 	phy_info_t *pi = (phy_info_t *) pih;
 	wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, MCTL_LOCK_RADIO);
 
-	OSL_DELAY(10);
+	udelay(10);
 }
 
 void wlc_radioreg_exit(wlc_phy_t *pih)
@@ -1316,20 +1316,20 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on)
 
 	while ((i++ < count)
 	       && (R_REG(pi->sh->osh, &regs->txe_status) & (1 << 7))) {
-		OSL_DELAY(10);
+		udelay(10);
 	}
 
 	i = 0;
 
 	while ((i++ < 10)
 	       && ((R_REG(pi->sh->osh, &regs->txe_status) & (1 << 10)) == 0)) {
-		OSL_DELAY(10);
+		udelay(10);
 	}
 
 	i = 0;
 
 	while ((i++ < 10) && ((R_REG(pi->sh->osh, &regs->ifsstat) & (1 << 8)))) {
-		OSL_DELAY(10);
+		udelay(10);
 	}
 	if (!pa_on) {
 		if (ISNPHY(pi))
drivers/staging/brcm80211/phy/wlc_phy_lcn.c +32 -32

228 lines not on this page · raw message

drivers/staging/brcm80211/phy/wlc_phy_n.c +38 -38

299 lines not on this page · raw message

drivers/staging/brcm80211/sys/wlc_ampdu.c +1 -1
index 796848f..0987e51 100644
@@ -939,7 +939,7 @@ wlc_ampdu_dotxstatus(ampdu_info_t *ampdu, struct scb *scb, void *p,
 		while (((s1 =
 			 R_REG(wlc->osh,
 			       &wlc->regs->frmtxstatus)) & TXS_V) == 0) {
-			OSL_DELAY(1);
+			udelay(1);
 			status_delay++;
 			if (status_delay > 10) {
 				ASSERT(status_delay <= 10);
drivers/staging/brcm80211/sys/wlc_bmac.c +15 -15
index 335c8db..afbbfad 100644
@@ -1324,10 +1324,10 @@ int wlc_bmac_down_finish(wlc_hw_info_t *wlc_hw)
 void wlc_bmac_wait_for_wake(wlc_hw_info_t *wlc_hw)
 {
 	if (D11REV_IS(wlc_hw->corerev, 4))	/* no slowclock */
-		OSL_DELAY(5);
+		udelay(5);
 	else {
 		/* delay before first read of ucode state */
-		OSL_DELAY(40);
+		udelay(40);
 
 		/* wait until ucode is no longer asleep */
 		SPINWAIT((wlc_bmac_read_shm(wlc_hw, M_UCODE_DBGST) ==
@@ -1373,7 +1373,7 @@ static void wlc_clkctl_clk(wlc_hw_info_t *wlc_hw, uint mode)
 				OR_REG(wlc_hw->osh, &wlc_hw->regs->clk_ctl_st,
 				       CCS_FORCEHT);
 
-				OSL_DELAY(64);
+				udelay(64);
 
 				SPINWAIT(((R_REG
 					   (wlc_hw->osh,
@@ -1981,16 +1981,16 @@ void wlc_bmac_core_phy_clk(wlc_hw_info_t *wlc_hw, bool clk)
 
 		si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE),
 			       (SICF_PRST | SICF_FGC));
-		OSL_DELAY(1);
+		udelay(1);
 		si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST);
-		OSL_DELAY(1);
+		udelay(1);
 
 	} else {		/* take phy out of reset */
 
 		si_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC);
-		OSL_DELAY(1);
+		udelay(1);
 		si_core_cflags(wlc_hw->sih, (SICF_FGC), 0);
-		OSL_DELAY(1);
+		udelay(1);
 
 	}
 }
@@ -2002,16 +2002,16 @@ void wlc_bmac_core_phypll_reset(wlc_hw_info_t *wlc_hw)
 
 	si_corereg(wlc_hw->sih, SI_CC_IDX,
 		   offsetof(chipcregs_t, chipcontrol_addr), ~0, 0);
-	OSL_DELAY(1);
+	udelay(1);
 	si_corereg(wlc_hw->sih, SI_CC_IDX,
 		   offsetof(chipcregs_t, chipcontrol_data), 0x4, 0);
-	OSL_DELAY(1);
+	udelay(1);
 	si_corereg(wlc_hw->sih, SI_CC_IDX,
 		   offsetof(chipcregs_t, chipcontrol_data), 0x4, 4);
-	OSL_DELAY(1);
+	udelay(1);
 	si_corereg(wlc_hw->sih, SI_CC_IDX,
 		   offsetof(chipcregs_t, chipcontrol_data), 0x4, 0);
-	OSL_DELAY(1);
+	udelay(1);
 }
 
 /* light way to turn on phy clock without reset for NPHY only
@@ -2057,7 +2057,7 @@ void wlc_bmac_phy_reset(wlc_hw_info_t *wlc_hw)
 		/* Set the PHY bandwidth */
 		si_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits);
 
-		OSL_DELAY(1);
+		udelay(1);
 
 		/* Perform a soft reset of the PHY PLL */
 		wlc_bmac_core_phypll_reset(wlc_hw);
@@ -2073,7 +2073,7 @@ void wlc_bmac_phy_reset(wlc_hw_info_t *wlc_hw)
 			       (SICF_PRST | SICF_PCLKE | phy_bw_clkbits));
 	}
 
-	OSL_DELAY(2);
+	udelay(2);
 	wlc_bmac_core_phy_clk(wlc_hw, ON);
 
 	if (pih)
@@ -2312,7 +2312,7 @@ static bool wlc_dma_rxreset(wlc_hw_info_t *wlc_hw, uint fifo)
 
 		if (!rxidle && (rcv_frm_cnt != 0))
 			WL_ERROR(("wl%d: %s: rxdma[%d] not idle && rcv_frm_cnt(%d) not zero\n", wlc_hw->unit, __func__, fifo, rcv_frm_cnt));
-		OSL_DELAY(2000);
+		mdelay(2);
 	}
 
 	return dma_rxreset(di);
@@ -3005,7 +3005,7 @@ u32 wlc_intrsoff(wlc_info_t *wlc)
 
 	W_REG(wlc_hw->osh, &wlc_hw->regs->macintmask, 0);
 	(void)R_REG(wlc_hw->osh, &wlc_hw->regs->macintmask);	/* sync readback */
-	OSL_DELAY(1);		/* ensure int line is no longer driven */
+	udelay(1);		/* ensure int line is no longer driven */
 	wlc->macintmask = 0;
 
 	/* return previous macintmask; resolve race between us and our isr */
drivers/staging/brcm80211/util/aiutils.c +4 -4
index 92573ab..1b47274 100644
@@ -591,10 +591,10 @@ void ai_core_disable(si_t *sih, u32 bits)
 
 	W_REG(sii->osh, &ai->ioctrl, bits);
 	dummy = R_REG(sii->osh, &ai->ioctrl);
-	OSL_DELAY(10);
+	udelay(10);
 
 	W_REG(sii->osh, &ai->resetctrl, AIRC_RESET);
-	OSL_DELAY(1);
+	udelay(1);
 }
 
 /* reset and re-enable a core
@@ -623,11 +623,11 @@ void ai_core_reset(si_t *sih, u32 bits, u32 resetbits)
 	W_REG(sii->osh, &ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN));
 	dummy = R_REG(sii->osh, &ai->ioctrl);
 	W_REG(sii->osh, &ai->resetctrl, 0);
-	OSL_DELAY(1);
+	udelay(1);
 
 	W_REG(sii->osh, &ai->ioctrl, (bits | SICF_CLOCK_EN));
 	dummy = R_REG(sii->osh, &ai->ioctrl);
-	OSL_DELAY(1);
+	udelay(1);
 }
 
 void ai_core_cflags_wo(si_t *sih, u32 mask, u32 val)
drivers/staging/brcm80211/util/bcmotp.c +1 -1
index fedebe2..30ad224 100644
@@ -695,7 +695,7 @@ static void *hndotp_init(si_t *sih)
 			    (clkdiv & ~CLKD_OTP) | (otpdiv << CLKD_OTP_SHIFT);
 			W_REG(osh, &cc->clkdiv, clkdiv);
 		}
-		OSL_DELAY(10);
+		udelay(10);
 
 		ret = (void *)oi;
 	}
drivers/staging/brcm80211/util/hnddma.c +4 -4
index 66c5609..4276f24 100644
@@ -1004,7 +1004,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di)
 #if defined(__mips__)
 	if (!len) {
 		while (!(len = *(u16 *) OSL_UNCACHED(PKTDATA(head))))
-			OSL_DELAY(1);
+			udelay(1);
 
 		*(u16 *) PKTDATA(head) = htol16((u16) len);
 	}
@@ -1599,7 +1599,7 @@ static bool dma32_txreset(dma_info_t *di)
 		  XS_XS_DISABLED), 10000);
 
 	/* wait for the last transaction to complete */
-	OSL_DELAY(300);
+	udelay(300);
 
 	return status == XS_XS_DISABLED;
 }
@@ -1649,7 +1649,7 @@ static bool dma32_txsuspendedidle(dma_info_t *di)
 	if ((R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK) != XS_XS_IDLE)
 		return 0;
 
-	OSL_DELAY(2);
+	udelay(2);
 	return ((R_REG(di->osh, &di->d32txregs->status) & XS_XS_MASK) ==
 		XS_XS_IDLE);
 }
@@ -2162,7 +2162,7 @@ static bool dma64_txreset(dma_info_t *di)
 		  != D64_XS0_XS_DISABLED), 10000);
 
 	/* wait for the last transaction to complete */
-	OSL_DELAY(300);
+	udelay(300);
 
 	return status == D64_XS0_XS_DISABLED;
 }
drivers/staging/brcm80211/util/hndpmu.c +7 -7
index cd71b74..819a1cf 100644
@@ -863,7 +863,7 @@ void si_pmu_res_init(si_t *sih, osl_t *osh)
 	}
 
 	/* Add some delay; allow resources to come up and settle. */
-	OSL_DELAY(2000);
+	mdelay(2);
 
 	/* Return to original core */
 	si_setcoreidx(sih, origidx);
@@ -1295,13 +1295,13 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal)
 		AND_REG(osh, &cc->max_res_mask,
 			~(PMURES_BIT(RES4319_HT_AVAIL)));
 
-		OSL_DELAY(100);
+		udelay(100);
 		AND_REG(osh, &cc->min_res_mask,
 			~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
 		AND_REG(osh, &cc->max_res_mask,
 			~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU)));
 
-		OSL_DELAY(100);
+		udelay(100);
 		SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL,
 			 PMU_MAX_TRANSITION_DLY);
 		ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL));
@@ -1317,7 +1317,7 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal)
 		AND_REG(osh, &cc->max_res_mask,
 			~(PMURES_BIT(RES4336_HT_AVAIL) |
 			  PMURES_BIT(RES4336_MACPHY_CLKAVAIL)));
-		OSL_DELAY(100);
+		udelay(100);
 		SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL,
 			 PMU_MAX_TRANSITION_DLY);
 		ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL));
@@ -1330,7 +1330,7 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal)
 		AND_REG(osh, &cc->max_res_mask,
 			~(PMURES_BIT(RES4330_HT_AVAIL) |
 			  PMURES_BIT(RES4330_MACPHY_CLKAVAIL)));
-		OSL_DELAY(100);
+		udelay(100);
 		SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL,
 			 PMU_MAX_TRANSITION_DLY);
 		ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL));
@@ -1854,7 +1854,7 @@ u32 si_pmu_ilp_clock(si_t *sih, osl_t *osh)
 		chipcregs_t *cc = si_setcoreidx(sih, SI_CC_IDX);
 		ASSERT(cc != NULL);
 		start = R_REG(osh, &cc->pmutimer);
-		OSL_DELAY(ILP_CALC_DUR * 1000);
+		mdelay(ILP_CALC_DUR);
 		end = R_REG(osh, &cc->pmutimer);
 		delta = end - start;
 		ilpcycles_per_sec = delta * (1000 / ILP_CALC_DUR);
@@ -2642,7 +2642,7 @@ u32 si_pmu_measure_alpclk(si_t *sih, osl_t *osh)
 		      1U << PMU_XTALFREQ_REG_MEASURE_SHIFT);
 
 		/* Delay for well over 4 ILP clocks */
-		OSL_DELAY(1000);
+		udelay(1000);
 
 		/* Read the latched number of ALP ticks per 4 ILP ticks */
 		ilp_ctr =
drivers/staging/brcm80211/util/linux_osl.c +0 -11
index a139232..f16731a 100644
@@ -591,17 +591,6 @@ void osl_assert(char *exp, char *file, int line)
 }
 #endif				/* defined(BCMDBG_ASSERT) */
 
-void osl_delay(uint usec)
-{
-	uint d;
-
-	while (usec > 0) {
-		d = min(usec, (uint)1000);
-		udelay(d);
-		usec -= d;
-	}
-}
-
 #if defined(BCMSDIO) && !defined(BRCM_FULLMAC)
 u8 osl_readb(osl_t *osh, volatile u8 *r)
 {
drivers/staging/brcm80211/util/nicpci.c +3 -3
index 6a9d9d6..cc031bd 100644
@@ -103,7 +103,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi);
 	} while (0)
 
 /* delay needed between the mdio control/ mdiodata register data access */
-#define PR28829_DELAY() OSL_DELAY(10)
+#define PR28829_DELAY() udelay(10)
 
 /* Initialize the PCI core. It's caller's responsibility to make sure that this is done
  * only once
@@ -281,7 +281,7 @@ static bool pcie_mdiosetblock(pcicore_info_t *pi, uint blk)
 		    MDIOCTL_ACCESS_DONE) {
 			break;
 		}
-		OSL_DELAY(1000);
+		udelay(1000);
 		i++;
 	}
 
@@ -342,7 +342,7 @@ pcie_mdioop(pcicore_info_t *pi, uint physmedia, uint regaddr, bool write,
 			W_REG(pi->osh, (&pcieregs->mdiocontrol), 0);
 			return 0;
 		}
-		OSL_DELAY(1000);
+		udelay(1000);
 		i++;
 	}
 
drivers/staging/brcm80211/util/sbutils.c +7 -7
index 06a1437..66fd89e 100644
@@ -477,7 +477,7 @@ void sb_core_disable(si_t *sih, u32 bits)
 	   (preserve core-specific bits) */
 	OR_SBREG(sii, &sb->sbtmstatelow, SBTML_REJ);
 	dummy = R_SBREG(sii, &sb->sbtmstatelow);
-	OSL_DELAY(1);
+	udelay(1);
 	SPINWAIT((R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_BUSY), 100000);
 	if (R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_BUSY)
 		SI_ERROR(("%s: target state still busy\n", __func__));
@@ -485,7 +485,7 @@ void sb_core_disable(si_t *sih, u32 bits)
 	if (R_SBREG(sii, &sb->sbidlow) & SBIDL_INIT) {
 		OR_SBREG(sii, &sb->sbimstate, SBIM_RJ);
 		dummy = R_SBREG(sii, &sb->sbimstate);
-		OSL_DELAY(1);
+		udelay(1);
 		SPINWAIT((R_SBREG(sii, &sb->sbimstate) & SBIM_BY), 100000);
 	}
 
@@ -494,7 +494,7 @@ void sb_core_disable(si_t *sih, u32 bits)
 		(((bits | SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
 		 SBTML_REJ | SBTML_RESET));
 	dummy = R_SBREG(sii, &sb->sbtmstatelow);
-	OSL_DELAY(10);
+	udelay(10);
 
 	/* don't forget to clear the initiator reject bit */
 	if (R_SBREG(sii, &sb->sbidlow) & SBIDL_INIT)
@@ -504,7 +504,7 @@ disable:
 	/* leave reset and reject asserted */
 	W_SBREG(sii, &sb->sbtmstatelow,
 		((bits << SBTML_SICF_SHIFT) | SBTML_REJ | SBTML_RESET));
-	OSL_DELAY(1);
+	udelay(1);
 }
 
 /* reset and re-enable a core
@@ -538,7 +538,7 @@ void sb_core_reset(si_t *sih, u32 bits, u32 resetbits)
 		(((bits | resetbits | SICF_FGC | SICF_CLOCK_EN) <<
 		  SBTML_SICF_SHIFT) | SBTML_RESET));
 	dummy = R_SBREG(sii, &sb->sbtmstatelow);
-	OSL_DELAY(1);
+	udelay(1);
 
 	if (R_SBREG(sii, &sb->sbtmstatehigh) & SBTMH_SERR)
 		W_SBREG(sii, &sb->sbtmstatehigh, 0);
@@ -552,13 +552,13 @@ void sb_core_reset(si_t *sih, u32 bits, u32 resetbits)
 		((bits | resetbits | SICF_FGC | SICF_CLOCK_EN) <<
 		 SBTML_SICF_SHIFT));
 	dummy = R_SBREG(sii, &sb->sbtmstatelow);
-	OSL_DELAY(1);
+	udelay(1);
 
 	/* leave clock enabled */
 	W_SBREG(sii, &sb->sbtmstatelow,
 		((bits | SICF_CLOCK_EN) << SBTML_SICF_SHIFT));
 	dummy = R_SBREG(sii, &sb->sbtmstatelow);
-	OSL_DELAY(1);
+	udelay(1);
 }
 
 u32 sb_base(u32 admatch)
drivers/staging/brcm80211/util/siutils.c +6 -6
index 5b945f2..dc1dd39 100644
@@ -152,7 +152,7 @@ static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid,
 				bcmsdh_cfg_write(sdh, SDIO_FUNC_1,
 						 SBSDIO_FUNC1_CHIPCLKCSR,
 						 clkset, &err);
-				OSL_DELAY(65);
+				udelay(65);
 			}
 		}
 
@@ -607,7 +607,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh,
 			W_REG(osh, &cc->clkdiv, clkdiv);
 			SI_ERROR(("%s: set clkdiv to %x\n", __func__, clkdiv));
 		}
-		OSL_DELAY(10);
+		udelay(10);
 	}
 
 	/* Init nvram from flash if it exists */
@@ -1308,7 +1308,7 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on)
 						     sizeof(u32), out);
 				OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUTEN,
 						     sizeof(u32), outen);
-				OSL_DELAY(XTAL_ON_DELAY);
+				udelay(XTAL_ON_DELAY);
 			}
 
 			/* turn pll on */
@@ -1316,7 +1316,7 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on)
 				out &= ~PCI_CFG_GPIO_PLL;
 				OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUT,
 						     sizeof(u32), out);
-				OSL_DELAY(2000);
+				mdelay(2);
 			}
 		} else {
 			if (what & XTAL)
@@ -1416,7 +1416,7 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode)
 				  == 0), PMU_MAX_TRANSITION_DLY);
 			ASSERT(R_REG(sii->osh, &cc->clk_ctl_st) & htavail);
 		} else {
-			OSL_DELAY(PLL_DELAY);
+			udelay(PLL_DELAY);
 		}
 		break;
 
@@ -2019,6 +2019,6 @@ void si_otp_power(si_t *sih, bool on)
 {
 	if (PMUCTL_ENAB(sih))
 		si_pmu_otp_power(sih, si_osh(sih), on);
-	OSL_DELAY(1000);
+	udelay(1000);
 }
 
Signature · 1 line
1.6.4.4
#2 lore raw

PATCH 2/7 staging: brcm80211: remove DHD_USE_STATIC_BUF

In reply to [email protected]

The DHD_USE_STATIC_BUF cannot be enabled in the build configuration, remove it.

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |   17 --
 drivers/staging/brcm80211/brcmfmac/dhd.h          |    4 +-
 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c      |   13 --
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c    |   21 ---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c     |   25 ---
 drivers/staging/brcm80211/include/linux_osl.h     |    5 -
 drivers/staging/brcm80211/util/linux_osl.c        |  180 ---------------------
 7 files changed, 1 insertions(+), 264 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +0 -17
index 1f277a3..05c89ad 100644
@@ -1040,11 +1040,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 	if (pkt == NULL) {
 		sd_data(("%s: Creating new %s Packet, len=%d\n",
 			 __func__, write ? "TX" : "RX", buflen_u));
-#ifdef DHD_USE_STATIC_BUF
-		mypkt = PKTGET_STATIC(sd->osh, buflen_u, write ? true : FALSE);
-#else
 		mypkt = PKTGET(sd->osh, buflen_u, write ? true : FALSE);
-#endif				/* DHD_USE_STATIC_BUF */
 		if (!mypkt) {
 			sd_err(("%s: PKTGET failed: len %d\n",
 				__func__, buflen_u));
@@ -1062,11 +1058,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 		if (!write)
 			bcopy(PKTDATA(mypkt), buffer, buflen_u);
 
-#ifdef DHD_USE_STATIC_BUF
-		PKTFREE_STATIC(sd->osh, mypkt, write ? true : FALSE);
-#else
 		PKTFREE(sd->osh, mypkt, write ? true : FALSE);
-#endif				/* DHD_USE_STATIC_BUF */
 	} else if (((u32) (PKTDATA(pkt)) & DMA_ALIGN_MASK) != 0) {
 		/* Case 2: We have a packet, but it is unaligned. */
 
@@ -1075,12 +1067,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 
 		sd_data(("%s: Creating aligned %s Packet, len=%d\n",
 			 __func__, write ? "TX" : "RX", PKTLEN(pkt)));
-#ifdef DHD_USE_STATIC_BUF
-		mypkt = PKTGET_STATIC(sd->osh, PKTLEN(pkt),
-					write ? true : FALSE);
-#else
 		mypkt = PKTGET(sd->osh, PKTLEN(pkt), write ? true : FALSE);
-#endif				/* DHD_USE_STATIC_BUF */
 		if (!mypkt) {
 			sd_err(("%s: PKTGET failed: len %d\n",
 				__func__, PKTLEN(pkt)));
@@ -1098,11 +1085,7 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 		if (!write)
 			bcopy(PKTDATA(mypkt), PKTDATA(pkt), PKTLEN(mypkt));
 
-#ifdef DHD_USE_STATIC_BUF
-		PKTFREE_STATIC(sd->osh, mypkt, write ? true : FALSE);
-#else
 		PKTFREE(sd->osh, mypkt, write ? true : FALSE);
-#endif				/* DHD_USE_STATIC_BUF */
 	} else {		/* case 3: We have a packet and
 				 it is aligned. */
 		sd_data(("%s: Aligned %s Packet, direct DMA\n",
drivers/staging/brcm80211/brcmfmac/dhd.h +1 -3
index 8ec3ebd..e0749d7 100644
@@ -73,9 +73,7 @@ enum dhd_prealloc_index {
 	DHD_PREALLOC_DATABUF,
 	DHD_PREALLOC_OSL_BUF
 };
-#ifdef DHD_USE_STATIC_BUF
-extern void *dhd_os_prealloc(int section, unsigned long size);
-#endif
+
 /* Common structure for module and instance linkage */
 typedef struct dhd_pub {
 	/* Linkage ponters */
drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +0 -13
index a8c385f..6c52f2b 100644
@@ -406,20 +406,11 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 {
 	dhd_prot_t *cdc;
 
-#ifndef DHD_USE_STATIC_BUF
 	cdc = (dhd_prot_t *) MALLOC(dhd->osh, sizeof(dhd_prot_t));
 	if (!cdc) {
 		DHD_ERROR(("%s: kmalloc failed\n", __func__));
 		goto fail;
 	}
-#else
-	cdc = (dhd_prot_t *) dhd_os_prealloc(DHD_PREALLOC_PROT,
-						sizeof(dhd_prot_t));
-	if (!cdc) {
-		DHD_ERROR(("%s: kmalloc failed\n", __func__));
-		goto fail;
-	}
-#endif				/* DHD_USE_STATIC_BUF */
 	memset(cdc, 0, sizeof(dhd_prot_t));
 
 	/* ensure that the msg buf directly follows the cdc msg struct */
@@ -436,19 +427,15 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 	return 0;
 
 fail:
-#ifndef DHD_USE_STATIC_BUF
 	if (cdc != NULL)
 		MFREE(dhd->osh, cdc, sizeof(dhd_prot_t));
-#endif
 	return BCME_NOMEM;
 }
 
 /* ~NOTE~ What if another thread is waiting on the semaphore?  Holding it? */
 void dhd_prot_detach(dhd_pub_t *dhd)
 {
-#ifndef DHD_USE_STATIC_BUF
 	MFREE(dhd->osh, dhd->prot, sizeof(dhd_prot_t));
-#endif
 	dhd->prot = NULL;
 }
 
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +0 -21
index 717e586..3bc2c4d 100644
@@ -2671,27 +2671,6 @@ void dhd_os_sdtxunlock(dhd_pub_t *pub)
 	dhd_os_sdunlock(pub);
 }
 
-#ifdef DHD_USE_STATIC_BUF
-void *dhd_os_prealloc(int section, unsigned long size)
-{
-#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
-	void *alloc_ptr = NULL;
-	if (wifi_control_data && wifi_control_data->mem_prealloc) {
-		alloc_ptr = wifi_control_data->mem_prealloc(section, size);
-		if (alloc_ptr) {
-			DHD_INFO(("success alloc section %d\n", section));
-			bzero(alloc_ptr, size);
-			return alloc_ptr;
-		}
-	}
-
-	DHD_ERROR(("can't alloc section %d\n", section));
-	return 0;
-#else
-	return MALLOC(0, size);
-#endif	/* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
-}
-#endif	/* DHD_USE_STATIC_BUF */
 #if defined(CONFIG_WIRELESS_EXT)
 struct iw_statistics *dhd_get_wireless_stats(struct net_device *dev)
 {
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +0 -25
index 363db37..96ebba1 100644
@@ -5382,7 +5382,6 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh)
 {
 	DHD_TRACE(("%s: Enter\n", __func__));
 
-#ifndef DHD_USE_STATIC_BUF
 	if (bus->dhd->maxctl) {
 		bus->rxblen =
 		    roundup((bus->dhd->maxctl + SDPCM_HDRLEN),
@@ -5405,26 +5404,6 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh)
 			MFREE(osh, bus->rxbuf, bus->rxblen);
 		goto fail;
 	}
-#else
-	if (bus->dhd->maxctl) {
-		bus->rxblen =
-		    roundup((bus->dhd->maxctl + SDPCM_HDRLEN),
-			    ALIGNMENT) + DHD_SDALIGN;
-		bus->rxbuf = dhd_os_prealloc(DHD_PREALLOC_RXBUF, bus->rxblen);
-		if (!(bus->rxbuf)) {
-			DHD_ERROR(("%s: MALLOC of %d-byte rxbuf failed\n",
-				   __func__, bus->rxblen));
-			goto fail;
-		}
-	}
-	/* Allocate buffer to receive glomed packet */
-	bus->databuf = dhd_os_prealloc(DHD_PREALLOC_DATABUF, MAX_DATA_BUF);
-	if (!(bus->databuf)) {
-		DHD_ERROR(("%s: MALLOC of %d-byte databuf failed\n",
-			   __func__, MAX_DATA_BUF));
-		goto fail;
-	}
-#endif				/* DHD_USE_STATIC_BUF */
 
 	/* Align the buffer */
 	if ((uintptr) bus->databuf % DHD_SDALIGN)
@@ -5583,17 +5562,13 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh)
 		return;
 
 	if (bus->rxbuf) {
-#ifndef DHD_USE_STATIC_BUF
 		MFREE(osh, bus->rxbuf, bus->rxblen);
-#endif
 		bus->rxctl = bus->rxbuf = NULL;
 		bus->rxlen = 0;
 	}
 
 	if (bus->databuf) {
-#ifndef DHD_USE_STATIC_BUF
 		MFREE(osh, bus->databuf, MAX_DATA_BUF);
-#endif
 		bus->databuf = NULL;
 	}
 }
drivers/staging/brcm80211/include/linux_osl.h +0 -5
index 12c9c32..006452e 100644
@@ -337,11 +337,6 @@ extern void *osl_pktget(osl_t *osh, uint len);
 extern void osl_pktfree(osl_t *osh, void *skb, bool send);
 
 #ifdef BRCM_FULLMAC
-#ifdef DHD_USE_STATIC_BUF
-#define	PKTGET_STATIC(osh, len, send)		osl_pktget_static((osh), (len))
-#define	PKTFREE_STATIC(osh, skb, send)	\
-	osl_pktfree_static((osh), (skb), (send))
-#endif
 extern void *osl_pktget_static(osl_t *osh, uint len);
 extern void osl_pktfree_static(osl_t *osh, void *skb, bool send);
 
drivers/staging/brcm80211/util/linux_osl.c +0 -180

216 lines not on this page · raw message

Signature · 1 line
1.6.4.4
#3 lore raw

PATCH 3/7 staging: brcm80211: remove osl_malloced()/MALLOCED()

In reply to [email protected]

because there are other means to track memory leaks in kernel

---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c       |    3 +--
 drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c |    6 ++----
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c |    3 +--
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c    |    4 ----
 drivers/staging/brcm80211/include/linux_osl.h     |    2 --
 drivers/staging/brcm80211/sys/wl_mac80211.c       |    9 ++-------
 drivers/staging/brcm80211/sys/wlc_alloc.c         |    3 +--
 drivers/staging/brcm80211/sys/wlc_ampdu.c         |    2 +-
 drivers/staging/brcm80211/sys/wlc_antsel.c        |    2 +-
 drivers/staging/brcm80211/sys/wlc_channel.c       |    3 +--
 drivers/staging/brcm80211/sys/wlc_phy_shim.c      |    2 +-
 drivers/staging/brcm80211/util/hnddma.c           |    7 +++----
 drivers/staging/brcm80211/util/linux_osl.c        |    6 ------
 drivers/staging/brcm80211/util/nicpci.c           |    3 +--
 drivers/staging/brcm80211/util/siutils.c          |    3 +--
 15 files changed, 16 insertions(+), 42 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +1 -2
index 42f1878..1b597e1 100644
@@ -60,8 +60,7 @@ bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq)
 
 	bcmsdh = (bcmsdh_info_t *) MALLOC(osh, sizeof(bcmsdh_info_t));
 	if (bcmsdh == NULL) {
-		BCMSDH_ERROR(("bcmsdh_attach: out of memory, "
-			"malloced %d bytes\n", MALLOCED(osh)));
+		BCMSDH_ERROR(("bcmsdh_attach: out of memory"));
 		return NULL;
 	}
 	bzero((char *)bcmsdh, sizeof(bcmsdh_info_t));
drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c +2 -4
index c6817b7..c6b9adc 100644
@@ -197,8 +197,7 @@ int bcmsdh_probe(struct device *dev)
 	}
 	sdhc = MALLOC(osh, sizeof(bcmsdh_hc_t));
 	if (!sdhc) {
-		SDLX_MSG(("%s: out of memory, allocated %d bytes\n",
-			  __func__, MALLOCED(osh)));
+		SDLX_MSG(("%s: out of memory\n", __func__));
 		goto err;
 	}
 	bzero(sdhc, sizeof(bcmsdh_hc_t));
@@ -430,8 +429,7 @@ bcmsdh_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 	sdhc = MALLOC(osh, sizeof(bcmsdh_hc_t));
 	if (!sdhc) {
-		SDLX_MSG(("%s: out of memory, allocated %d bytes\n",
-			  __func__, MALLOCED(osh)));
+		SDLX_MSG(("%s: out of memory\n", __func__));
 		goto err;
 	}
 	bzero(sdhc, sizeof(bcmsdh_hc_t));
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +1 -2
index 05c89ad..b8003db 100644
@@ -125,8 +125,7 @@ extern sdioh_info_t *sdioh_attach(osl_t *osh, void *bar0, uint irq)
 
 	sd = (sdioh_info_t *) MALLOC(osh, sizeof(sdioh_info_t));
 	if (sd == NULL) {
-		sd_err(("sdioh_attach: out of memory, malloced %d bytes\n",
-			MALLOCED(osh)));
+		sd_err(("sdioh_attach: out of memory\n"));
 		return NULL;
 	}
 	bzero((char *)sd, sizeof(sdioh_info_t));
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +0 -4
index 3bc2c4d..224f426 100644
@@ -1823,10 +1823,6 @@ osl_t *dhd_osl_attach(void *pdev, uint bustype)
 
 void dhd_osl_detach(osl_t *osh)
 {
-	if (MALLOCED(osh)) {
-		DHD_ERROR(("%s: MEMORY LEAK %d bytes\n", __func__,
-			   MALLOCED(osh)));
-	}
 	osl_detach(osh);
 }
 
drivers/staging/brcm80211/include/linux_osl.h +0 -2
index 006452e..9273301 100644
@@ -96,10 +96,8 @@ typedef struct {
 
 #define MALLOC(osh, size)	osl_malloc((osh), (size))
 #define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
-#define MALLOCED(osh)		osl_malloced((osh))
 extern void *osl_malloc(osl_t *osh, uint size);
 extern void osl_mfree(osl_t *osh, void *addr, uint size);
-extern uint osl_malloced(osl_t *osh);
 
 #define NATIVE_MALLOC(osh, size)	kmalloc(size, GFP_ATOMIC)
 #define NATIVE_MFREE(osh, addr, size)	kfree(addr)
drivers/staging/brcm80211/sys/wl_mac80211.c +2 -7
index 7a3116b..e43f05a 100644
@@ -1615,11 +1615,6 @@ void wl_free(wl_info_t *wl)
 	}
 #endif				/* WLC_HIGH_ONLY */
 
-	if (osl_malloced(osh)) {
-		printf("****   Memory leak of bytes %d\n", osl_malloced(osh));
-		ASSERT(0 && "Memory Leak");
-	}
-
 	osl_detach(osh);
 }
 
@@ -1664,7 +1659,7 @@ wl_schedule_task(wl_info_t *wl, void (*fn) (struct wl_task *task),
 
 	task = osl_malloc(wl->osh, sizeof(wl_task_t));
 	if (!task) {
-		WL_ERROR(("wl%d: wl_schedule_task: out of memory, malloced %d bytes\n", wl->pub->unit, osl_malloced(wl->osh)));
+		WL_ERROR(("wl%d: wl_schedule_task: out of memory\n", wl->pub->unit));
 		return -ENOMEM;
 	}
 
@@ -1918,7 +1913,7 @@ wl_timer_t *wl_init_timer(wl_info_t *wl, void (*fn) (void *arg), void *arg,
 
 	t = osl_malloc(wl->osh, sizeof(wl_timer_t));
 	if (!t) {
-		WL_ERROR(("wl%d: wl_init_timer: out of memory, malloced %d bytes\n", wl->pub->unit, osl_malloced(wl->osh)));
+		WL_ERROR(("wl%d: wl_init_timer: out of memory\n", wl->pub->unit));
 		return 0;
 	}
 
drivers/staging/brcm80211/sys/wlc_alloc.c +1 -2
index 9c902d7..e637e62 100644
@@ -39,8 +39,7 @@ void *wlc_calloc(osl_t *osh, uint unit, uint size)
 
 	item = MALLOC(osh, size);
 	if (item == NULL)
-		WL_ERROR(("wl%d: %s: out of memory, malloced %d bytes\n",
-			  unit, __func__, MALLOCED(osh)));
+		WL_ERROR(("wl%d: %s: out of memory\n", unit, __func__));
 	else
 		bzero((char *)item, size);
 	return item;
drivers/staging/brcm80211/sys/wlc_ampdu.c +1 -1
index 0987e51..26bc9cc 100644
@@ -181,7 +181,7 @@ ampdu_info_t *wlc_ampdu_attach(wlc_info_t *wlc)
 
 	ampdu = (ampdu_info_t *) MALLOC(wlc->osh, sizeof(ampdu_info_t));
 	if (!ampdu) {
-		WL_ERROR(("wl%d: wlc_ampdu_attach: out of mem, malloced %d bytes\n", wlc->pub->unit, MALLOCED(wlc->osh)));
+		WL_ERROR(("wl%d: wlc_ampdu_attach: out of mem\n", wlc->pub->unit));
 		return NULL;
 	}
 	bzero((char *)ampdu, sizeof(ampdu_info_t));
drivers/staging/brcm80211/sys/wlc_antsel.c +1 -1
index 671a0aa..ee1cefd 100644
@@ -96,7 +96,7 @@ antsel_info_t *wlc_antsel_attach(wlc_info_t *wlc, osl_t *osh,
 
 	asi = (antsel_info_t *) MALLOC(osh, sizeof(antsel_info_t));
 	if (!asi) {
-		WL_ERROR(("wl%d: wlc_antsel_attach: out of mem, malloced %d bytes\n", pub->unit, MALLOCED(osh)));
+		WL_ERROR(("wl%d: wlc_antsel_attach: out of mem\n", pub->unit));
 		return NULL;
 	}
 
drivers/staging/brcm80211/sys/wlc_channel.c +1 -2
index ae152bb..f62144a 100644
@@ -614,8 +614,7 @@ wlc_cm_info_t *wlc_channel_mgr_attach(wlc_info_t *wlc)
 
 	wlc_cm = (wlc_cm_info_t *) MALLOC(pub->osh, sizeof(wlc_cm_info_t));
 	if (wlc_cm == NULL) {
-		WL_ERROR(("wl%d: %s: out of memory, malloced %d bytes",
-			  pub->unit, __func__, MALLOCED(pub->osh)));
+		WL_ERROR(("wl%d: %s: out of memory", pub->unit, __func__));
 		return NULL;
 	}
 	bzero((char *)wlc_cm, sizeof(wlc_cm_info_t));
drivers/staging/brcm80211/sys/wlc_phy_shim.c +1 -1
index 7c8193a..37bb593 100644
@@ -69,7 +69,7 @@ wlc_phy_shim_info_t *wlc_phy_shim_attach(wlc_hw_info_t *wlc_hw,
 	physhim = (wlc_phy_shim_info_t *)MALLOC(wlc_hw->osh,
 		sizeof(wlc_phy_shim_info_t));
 	if (!physhim) {
-		WL_ERROR(("wl%d: wlc_phy_shim_attach: out of mem, malloced %d bytes\n", wlc_hw->unit, MALLOCED(wlc_hw->osh)));
+		WL_ERROR(("wl%d: wlc_phy_shim_attach: out of mem\n", wlc_hw->unit));
 		return NULL;
 	}
 	bzero((char *)physhim, sizeof(wlc_phy_shim_info_t));
drivers/staging/brcm80211/util/hnddma.c +3 -4
index 4276f24..cb99a23 100644
@@ -381,8 +381,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 	di = MALLOC(osh, sizeof(dma_info_t));
 	if (di == NULL) {
 #ifdef BCMDBG
-		printf("dma_attach: out of memory, malloced %d bytes\n",
-		       MALLOCED(osh));
+		printf("dma_attach: out of memory\n");
 #endif
 		return NULL;
 	}
@@ -517,7 +516,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 		size = ntxd * sizeof(void *);
 		di->txp = MALLOC(osh, size);
 		if (di->txp == NULL) {
-			DMA_ERROR(("%s: dma_attach: out of tx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
+			DMA_ERROR(("%s: dma_attach: out of tx memory\n", di->name));
 			goto fail;
 		}
 		bzero((char *)di->txp, size);
@@ -528,7 +527,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 		size = nrxd * sizeof(void *);
 		di->rxp = MALLOC(osh, size);
 		if (di->rxp == NULL) {
-			DMA_ERROR(("%s: dma_attach: out of rx memory, malloced %d bytes\n", di->name, MALLOCED(osh)));
+			DMA_ERROR(("%s: dma_attach: out of rx memory\n", di->name));
 			goto fail;
 		}
 		bzero((char *)di->rxp, size);
drivers/staging/brcm80211/util/linux_osl.c +0 -6
index 15c236a..7f4da18 100644
@@ -314,12 +314,6 @@ void osl_mfree(osl_t *osh, void *addr, uint size)
 	kfree(addr);
 }
 
-uint osl_malloced(osl_t *osh)
-{
-	ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
-	return osh->malloced;
-}
-
 uint osl_dma_consistent_align(void)
 {
 	return PAGE_SIZE;
drivers/staging/brcm80211/util/nicpci.c +1 -2
index cc031bd..1c7a21c 100644
@@ -117,8 +117,7 @@ void *pcicore_init(si_t *sih, osl_t *osh, void *regs)
 	/* alloc pcicore_info_t */
 	pi = MALLOC(osh, sizeof(pcicore_info_t));
 	if (pi == NULL) {
-		PCI_ERROR(("pci_attach: malloc failed! malloced %d bytes\n",
-			   MALLOCED(osh)));
+		PCI_ERROR(("pci_attach: malloc failed!\n"));
 		return NULL;
 	}
 
drivers/staging/brcm80211/util/siutils.c +1 -2
index dc1dd39..ec21dbd 100644
@@ -90,8 +90,7 @@ si_t *si_attach(uint devid, osl_t *osh, void *regs, uint bustype, void *sdh,
 	/* alloc si_info_t */
 	sii = MALLOC(osh, sizeof(si_info_t));
 	if (sii == NULL) {
-		SI_ERROR(("si_attach: malloc failed! malloced %d bytes\n",
-			  MALLOCED(osh)));
+		SI_ERROR(("si_attach: malloc failed!\n"));
 		return NULL;
 	}
 
Signature · 1 line
1.6.4.4
#4 lore raw

PATCH 4/7 staging: brcm80211: replace MALLOC() with k[zm]alloc

In reply to [email protected]
---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c        |    5 +--
 drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c  |    6 +--
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c  |    3 +-
 .../brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c        |    2 +-
 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c       |    3 +-
 drivers/staging/brcm80211/brcmfmac/dhd_common.c    |    8 ++--
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |   10 +++---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |   39 ++++++++++----------
 drivers/staging/brcm80211/include/linux_osl.h      |    2 -
 drivers/staging/brcm80211/phy/wlc_phy_cmn.c        |    6 +--
 drivers/staging/brcm80211/phy/wlc_phy_lcn.c        |   13 +++----
 drivers/staging/brcm80211/phy/wlc_phy_n.c          |    6 ++--
 drivers/staging/brcm80211/sys/wl_mac80211.c        |    6 ++--
 drivers/staging/brcm80211/sys/wlc_alloc.c          |    4 +--
 drivers/staging/brcm80211/sys/wlc_ampdu.c          |    3 +-
 drivers/staging/brcm80211/sys/wlc_antsel.c         |    4 +--
 drivers/staging/brcm80211/sys/wlc_channel.c        |    3 +-
 drivers/staging/brcm80211/sys/wlc_event.c          |    7 +---
 drivers/staging/brcm80211/sys/wlc_phy_shim.c       |    4 +--
 drivers/staging/brcm80211/util/bcmotp.c            |    2 +-
 drivers/staging/brcm80211/util/bcmsrom.c           |   20 ++++------
 drivers/staging/brcm80211/util/hnddma.c            |   16 +++------
 drivers/staging/brcm80211/util/linux_osl.c         |   20 ----------
 drivers/staging/brcm80211/util/nicpci.c            |    4 +--
 drivers/staging/brcm80211/util/nvram/nvram_ro.c    |    5 ++-
 drivers/staging/brcm80211/util/siutils.c           |    2 +-
 26 files changed, 74 insertions(+), 129 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +2 -3
index 1b597e1..708575e 100644
@@ -58,12 +58,11 @@ bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq)
 {
 	bcmsdh_info_t *bcmsdh;
 
-	bcmsdh = (bcmsdh_info_t *) MALLOC(osh, sizeof(bcmsdh_info_t));
+	bcmsdh = kzalloc(sizeof(bcmsdh_info_t), GFP_ATOMIC);
 	if (bcmsdh == NULL) {
 		BCMSDH_ERROR(("bcmsdh_attach: out of memory"));
 		return NULL;
 	}
-	bzero((char *)bcmsdh, sizeof(bcmsdh_info_t));
 
 	/* save the handler locally */
 	l_bcmsdh = bcmsdh;
@@ -317,7 +316,7 @@ int bcmsdh_cis_read(void *sdh, uint func, u8 * cis, uint length)
 	if (ascii) {
 		/* Move binary bits to tmp and format them
 			 into the provided buffer. */
-		tmp_buf = (u8 *) MALLOC(bcmsdh->osh, length);
+		tmp_buf = kmalloc(length, GFP_ATOMIC);
 		if (tmp_buf == NULL) {
 			BCMSDH_ERROR(("%s: out of memory\n", __func__));
 			return BCME_NOMEM;
drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c +2 -4
index c6b9adc..9be6eb6 100644
@@ -195,12 +195,11 @@ int bcmsdh_probe(struct device *dev)
 		SDLX_MSG(("%s: osl_attach failed\n", __func__));
 		goto err;
 	}
-	sdhc = MALLOC(osh, sizeof(bcmsdh_hc_t));
+	sdhc = kzalloc(sizeof(bcmsdh_hc_t), GFP_ATOMIC);
 	if (!sdhc) {
 		SDLX_MSG(("%s: out of memory\n", __func__));
 		goto err;
 	}
-	bzero(sdhc, sizeof(bcmsdh_hc_t));
 	sdhc->osh = osh;
 
 	sdhc->dev = (void *)dev;
@@ -427,12 +426,11 @@ bcmsdh_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		SDLX_MSG(("%s: osl_attach failed\n", __func__));
 		goto err;
 	}
-	sdhc = MALLOC(osh, sizeof(bcmsdh_hc_t));
+	sdhc = kzalloc(sizeof(bcmsdh_hc_t), GFP_ATOMIC);
 	if (!sdhc) {
 		SDLX_MSG(("%s: out of memory\n", __func__));
 		goto err;
 	}
-	bzero(sdhc, sizeof(bcmsdh_hc_t));
 	sdhc->osh = osh;
 
 	sdhc->dev = pdev;
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +1 -2
index b8003db..c54da99 100644
@@ -123,12 +123,11 @@ extern sdioh_info_t *sdioh_attach(osl_t *osh, void *bar0, uint irq)
 		return NULL;
 	}
 
-	sd = (sdioh_info_t *) MALLOC(osh, sizeof(sdioh_info_t));
+	sd = kzalloc(sizeof(sdioh_info_t), GFP_ATOMIC);
 	if (sd == NULL) {
 		sd_err(("sdioh_attach: out of memory\n"));
 		return NULL;
 	}
-	bzero((char *)sd, sizeof(sdioh_info_t));
 	sd->osh = osh;
 	if (sdioh_sdmmc_osinit(sd) != 0) {
 		sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__));
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c +1 -1
index ac89f82..7a80bcf 100644
@@ -148,7 +148,7 @@ int sdioh_sdmmc_osinit(sdioh_info_t *sd)
 {
 	struct sdos_info *sdos;
 
-	sdos = (struct sdos_info *)MALLOC(sd->osh, sizeof(struct sdos_info));
+	sdos = kmalloc(sizeof(struct sdos_info), GFP_ATOMIC);
 	sd->sdos_info = (void *)sdos;
 	if (sdos == NULL)
 		return BCME_NOMEM;
drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +1 -2
index 6c52f2b..3f8d1fd 100644
@@ -406,12 +406,11 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 {
 	dhd_prot_t *cdc;
 
-	cdc = (dhd_prot_t *) MALLOC(dhd->osh, sizeof(dhd_prot_t));
+	cdc = kzalloc(sizeof(dhd_prot_t), GFP_ATOMIC);
 	if (!cdc) {
 		DHD_ERROR(("%s: kmalloc failed\n", __func__));
 		goto fail;
 	}
-	memset(cdc, 0, sizeof(dhd_prot_t));
 
 	/* ensure that the msg buf directly follows the cdc msg struct */
 	if ((uintptr) (&cdc->msg + 1) != (uintptr) cdc->buf) {
drivers/staging/brcm80211/brcmfmac/dhd_common.c +4 -4
index 36084e4..0d17ed0 100644
@@ -998,7 +998,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 	wl_pkt_filter_enable_t enable_parm;
 	wl_pkt_filter_enable_t *pkt_filterp;
 
-	arg_save = MALLOC(dhd->osh, strlen(arg) + 1);
+	arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
 	if (!arg_save) {
 		DHD_ERROR(("%s: kmalloc failed\n", __func__));
 		goto fail;
@@ -1070,7 +1070,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	char *arg_save = 0, *arg_org = 0;
 #define BUF_SIZE		2048
 
-	arg_save = MALLOC(dhd->osh, strlen(arg) + 1);
+	arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
 	if (!arg_save) {
 		DHD_ERROR(("%s: kmalloc failed\n", __func__));
 		goto fail;
@@ -1078,7 +1078,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 	arg_org = arg_save;
 
-	buf = MALLOC(dhd->osh, BUF_SIZE);
+	buf = kmalloc(BUF_SIZE, GFP_ATOMIC);
 	if (!buf) {
 		DHD_ERROR(("%s: kmalloc failed\n", __func__));
 		goto fail;
@@ -1363,7 +1363,7 @@ iscan_buf_t *dhd_iscan_allocate_buf(dhd_pub_t *dhd, iscan_buf_t **iscanbuf)
 
 	dhd_iscan_lock();
 
-	iscanbuf_alloc = (iscan_buf_t *) MALLOC(dhd->osh, sizeof(iscan_buf_t));
+	iscanbuf_alloc = kmalloc(sizeof(iscan_buf_t), GFP_ATOMIC);
 	if (iscanbuf_alloc == NULL)
 		goto fail;
 
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +5 -5
index 224f426..27106ab 100644
@@ -712,7 +712,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 	/* Send down the multicast list first. */
 
 	buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETHER_ADDR_LEN);
-	bufp = buf = MALLOC(dhd->pub.osh, buflen);
+	bufp = buf = kmalloc(buflen, GFP_ATOMIC);
 	if (!bufp) {
 		DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
 			   dhd_ifname(&dhd->pub, ifidx), cnt));
@@ -755,7 +755,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 	 */
 
 	buflen = sizeof("allmulti") + sizeof(allmulti);
-	buf = MALLOC(dhd->pub.osh, buflen);
+	buf = kmalloc(buflen, GFP_ATOMIC);
 	if (!buf) {
 		DHD_ERROR(("%s: out of memory for allmulti\n",
 			   dhd_ifname(&dhd->pub, ifidx)));
@@ -1672,7 +1672,7 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 		   } else {
 		 */
 		{
-			buf = (char *)MALLOC(dhd->pub.osh, buflen);
+			buf = kmalloc(buflen, GFP_ATOMIC);
 			if (!buf) {
 				bcmerror = -BCME_NOMEM;
 				goto done;
@@ -1837,7 +1837,7 @@ dhd_add_if(dhd_info_t *dhd, int ifidx, void *handle, char *name,
 	ASSERT(dhd && (ifidx < DHD_MAX_IFS));
 
 	ifp = dhd->iflist[ifidx];
-	if (!ifp && !(ifp = MALLOC(dhd->pub.osh, sizeof(dhd_if_t)))) {
+	if (!ifp && !(ifp = kmalloc(sizeof(dhd_if_t), GFP_ATOMIC))) {
 		DHD_ERROR(("%s: OOM - dhd_if_t\n", __func__));
 		return -ENOMEM;
 	}
@@ -1900,7 +1900,7 @@ dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 	}
 
 	/* Allocate primary dhd_info */
-	dhd = MALLOC(osh, sizeof(dhd_info_t));
+	dhd = kmalloc(sizeof(dhd_info_t), GFP_ATOMIC);
 	if (!dhd) {
 		DHD_ERROR(("%s: OOM - alloc dhd_info\n", __func__));
 		goto fail;
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +19 -20
index 96ebba1..f9605f9 100644
@@ -1822,18 +1822,18 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 		 * allocate memory to trace the trap or assert.
 		 */
 		size = msize;
-		mbuffer = data = MALLOC(bus->dhd->osh, msize);
+		mbuffer = data = kmalloc(msize, GFP_ATOMIC);
 		if (mbuffer == NULL) {
-			DHD_ERROR(("%s: MALLOC(%d) failed\n", __func__,
+			DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__,
 				   msize));
 			bcmerror = BCME_NOMEM;
 			goto done;
 		}
 	}
 
-	str = MALLOC(bus->dhd->osh, maxstrlen);
+	str = kmalloc(maxstrlen, GFP_ATOMIC);
 	if (str == NULL) {
-		DHD_ERROR(("%s: MALLOC(%d) failed\n", __func__, maxstrlen));
+		DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__, maxstrlen));
 		bcmerror = BCME_NOMEM;
 		goto done;
 	}
@@ -1944,7 +1944,7 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus)
 
 	/* Get full mem size */
 	size = bus->ramsize;
-	buf = MALLOC(bus->dhd->osh, size);
+	buf = kmalloc(size, GFP_ATOMIC);
 	if (!buf) {
 		printf("%s: Out of memory (%d bytes)\n", __func__, size);
 		return -1;
@@ -2004,7 +2004,7 @@ static int dhdsdio_readconsole(dhd_bus_t *bus)
 	/* Allocate console buffer (one time only) */
 	if (c->buf == NULL) {
 		c->bufsize = ltoh32(c->log.buf_size);
-		c->buf = MALLOC(bus->dhd->osh, c->bufsize);
+		c->buf = kmalloc(c->bufsize, GFP_ATOMIC);
 		if (c->buf == NULL)
 			return BCME_NOMEM;
 	}
@@ -2080,7 +2080,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len)
 	if (bus->vars)
 		MFREE(bus->dhd->osh, bus->vars, bus->varsz);
 
-	bus->vars = MALLOC(bus->dhd->osh, len);
+	bus->vars = kmalloc(len, GFP_ATOMIC);
 	bus->varsz = bus->vars ? len : 0;
 	if (bus->vars == NULL) {
 		bcmerror = BCME_NOMEM;
@@ -2526,7 +2526,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 	varaddr = (bus->ramsize - 4) - varsize;
 
 	if (bus->vars) {
-		vbuffer = (u8 *) MALLOC(bus->dhd->osh, varsize);
+		vbuffer = kmalloc(varsize, GFP_ATOMIC);
 		if (!vbuffer)
 			return BCME_NOMEM;
 
@@ -2539,7 +2539,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 #ifdef DHD_DEBUG
 		/* Verify NVRAM bytes */
 		DHD_INFO(("Compare NVRAM dl & ul; varsize=%d\n", varsize));
-		nvram_ularray = (char *)MALLOC(bus->dhd->osh, varsize);
+		nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
 		if (!nvram_ularray)
 			return BCME_NOMEM;
 
@@ -5147,12 +5147,11 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
 	}
 
 	/* Allocate private bus interface state */
-	bus = MALLOC(osh, sizeof(dhd_bus_t));
+	bus = kzalloc(sizeof(dhd_bus_t), GFP_ATOMIC);
 	if (!bus) {
-		DHD_ERROR(("%s: MALLOC of dhd_bus_t failed\n", __func__));
+		DHD_ERROR(("%s: kmalloc of dhd_bus_t failed\n", __func__));
 		goto fail;
 	}
-	bzero(bus, sizeof(dhd_bus_t));
 	bus->sdh = sdh;
 	bus->cl_devid = (u16) devid;
 	bus->bus = DHD_BUS;
@@ -5274,7 +5273,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva,
 		udelay(65);
 
 		for (fn = 0; fn <= numfn; fn++) {
-			cis[fn] = MALLOC(osh, SBSDIO_CIS_SIZE_LIMIT);
+			cis[fn] = kmalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC);
 			if (!cis[fn]) {
 				DHD_INFO(("dhdsdio_probe: fn %d cis malloc "
 					"failed\n", fn));
@@ -5386,18 +5385,18 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh)
 		bus->rxblen =
 		    roundup((bus->dhd->maxctl + SDPCM_HDRLEN),
 			    ALIGNMENT) + DHD_SDALIGN;
-		bus->rxbuf = MALLOC(osh, bus->rxblen);
+		bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC);
 		if (!(bus->rxbuf)) {
-			DHD_ERROR(("%s: MALLOC of %d-byte rxbuf failed\n",
+			DHD_ERROR(("%s: kmalloc of %d-byte rxbuf failed\n",
 				   __func__, bus->rxblen));
 			goto fail;
 		}
 	}
 
 	/* Allocate buffer to receive glomed packet */
-	bus->databuf = MALLOC(osh, MAX_DATA_BUF);
+	bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC);
 	if (!(bus->databuf)) {
-		DHD_ERROR(("%s: MALLOC of %d-byte databuf failed\n",
+		DHD_ERROR(("%s: kmalloc of %d-byte databuf failed\n",
 			   __func__, MAX_DATA_BUF));
 		/* release rxbuf which was already located as above */
 		if (!bus->rxblen)
@@ -5672,7 +5671,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 	{
 		unsigned char *ularray;
 
-		ularray = MALLOC(bus->dhd->osh, bus->ramsize);
+		ularray = kmalloc(bus->ramsize, GFP_ATOMIC);
 		/* Upload image to verify downloaded contents. */
 		offset = 0;
 		memset(ularray, 0xaa, bus->ramsize);
@@ -5734,7 +5733,7 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path)
 	if (image == NULL)
 		goto err;
 
-	memptr = memblock = MALLOC(bus->dhd->osh, MEMBLOCK + DHD_SDALIGN);
+	memptr = memblock = kmalloc(MEMBLOCK + DHD_SDALIGN, GFP_ATOMIC);
 	if (memblock == NULL) {
 		DHD_ERROR(("%s: Failed to allocate memory %d bytes\n",
 			   __func__, MEMBLOCK));
@@ -5861,7 +5860,7 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus)
 			goto err;
 	}
 
-	memblock = MALLOC(bus->dhd->osh, MEMBLOCK);
+	memblock = kmalloc(MEMBLOCK, GFP_ATOMIC);
 	if (memblock == NULL) {
 		DHD_ERROR(("%s: Failed to allocate memory %d bytes\n",
 			   __func__, MEMBLOCK));
drivers/staging/brcm80211/include/linux_osl.h +0 -2
index 9273301..69f0e84 100644
@@ -94,9 +94,7 @@ typedef struct {
 
 #define BUS_SWAP32(v)		(v)
 
-#define MALLOC(osh, size)	osl_malloc((osh), (size))
 #define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
-extern void *osl_malloc(osl_t *osh, uint size);
 extern void osl_mfree(osl_t *osh, void *addr, uint size);
 
 #define NATIVE_MALLOC(osh, size)	kmalloc(size, GFP_ATOMIC)
drivers/staging/brcm80211/phy/wlc_phy_cmn.c +2 -4
index 5da1597..739fe71 100644
@@ -555,11 +555,10 @@ shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp)
 {
 	shared_phy_t *sh;
 
-	sh = (shared_phy_t *) MALLOC(shp->osh, sizeof(shared_phy_t));
+	sh = kzalloc(sizeof(shared_phy_t), GFP_ATOMIC);
 	if (sh == NULL) {
 		return NULL;
 	}
-	bzero((char *)sh, sizeof(shared_phy_t));
 
 	sh->osh = shp->osh;
 	sh->sih = shp->sih;
@@ -633,11 +632,10 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars
 		return &pi->pubpi_ro;
 	}
 
-	pi = (phy_info_t *) MALLOC(osh, sizeof(phy_info_t));
+	pi = kzalloc(sizeof(phy_info_t), GFP_ATOMIC);
 	if (pi == NULL) {
 		return NULL;
 	}
-	bzero((char *)pi, sizeof(phy_info_t));
 	pi->regs = (d11regs_t *) regs;
 	pi->sh = sh;
 	pi->phy_init_por = true;
drivers/staging/brcm80211/phy/wlc_phy_lcn.c +5 -8
index 40b081c..1a70f9a 100644
@@ -1882,7 +1882,7 @@ wlc_lcnphy_tx_iqlo_cal(phy_info_t *pi,
 	if (NORADIO_ENAB(pi->pubpi))
 		return;
 
-	values_to_save = MALLOC(pi->sh->osh, sizeof(u16) * 20);
+	values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
 	if (NULL == values_to_save) {
 		return;
 	}
@@ -3289,7 +3289,7 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
 	s16 *ptr;
 	phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy;
 
-	ptr = MALLOC(pi->sh->osh, sizeof(s16) * 131);
+	ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
 	if (NULL == ptr) {
 		return FALSE;
 	}
@@ -4038,12 +4038,12 @@ wlc_lcnphy_a1(phy_info_t *pi, int cal_type, int num_levels, int step_size_lg2)
 	u16 *phy_c32;
 	phy_c21 = 0;
 	phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0;
-	ptr = MALLOC(pi->sh->osh, sizeof(s16) * 131);
+	ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
 	if (NULL == ptr) {
 		return;
 	}
 
-	phy_c32 = MALLOC(pi->sh->osh, sizeof(u16) * 20);
+	phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
 	if (NULL == phy_c32) {
 		return;
 	}
@@ -5054,13 +5054,10 @@ bool wlc_phy_attach_lcnphy(phy_info_t *pi)
 {
 	phy_info_lcnphy_t *pi_lcn;
 
-	pi->u.pi_lcnphy =
-	    (phy_info_lcnphy_t *) MALLOC(pi->sh->osh,
-					 sizeof(phy_info_lcnphy_t));
+	pi->u.pi_lcnphy = kzalloc(sizeof(phy_info_lcnphy_t), GFP_ATOMIC);
 	if (pi->u.pi_lcnphy == NULL) {
 		return FALSE;
 	}
-	bzero((char *)pi->u.pi_lcnphy, sizeof(phy_info_lcnphy_t));
 
 	pi_lcn = pi->u.pi_lcnphy;
 
drivers/staging/brcm80211/phy/wlc_phy_n.c +3 -3
index dd856c4..529e06c 100644
@@ -22360,7 +22360,7 @@ wlc_phy_gen_load_samples_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val,
 		tbl_len = (phy_bw << 1);
 	}
 
-	tone_buf = (cs32 *) MALLOC(pi->sh->osh, sizeof(cs32) * tbl_len);
+	tone_buf = kmalloc(sizeof(cs32) * tbl_len, GFP_ATOMIC);
 	if (tone_buf == NULL) {
 		return 0;
 	}
@@ -22414,7 +22414,7 @@ wlc_phy_loadsampletable_nphy(phy_info_t *pi, cs32 *tone_buf,
 	u16 t;
 	u32 *data_buf = NULL;
 
-	data_buf = (u32 *) MALLOC(pi->sh->osh, sizeof(u32) * num_samps);
+	data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC);
 	if (data_buf == NULL) {
 		return;
 	}
@@ -26727,7 +26727,7 @@ wlc_phy_a1_nphy(phy_info_t *pi, u8 core, u32 winsz, u32 start,
 	ASSERT(end > start);
 	ASSERT(end < NPHY_PAPD_EPS_TBL_SIZE);
 
-	buf = MALLOC(pi->sh->osh, 2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE);
+	buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC);
 	if (NULL == buf) {
 		return;
 	}
drivers/staging/brcm80211/sys/wl_mac80211.c +3 -3
index e43f05a..bcd6e69 100644
@@ -1657,7 +1657,7 @@ wl_schedule_task(wl_info_t *wl, void (*fn) (struct wl_task *task),
 
 	WL_TRACE(("wl%d: wl_schedule_task\n", wl->pub->unit));
 
-	task = osl_malloc(wl->osh, sizeof(wl_task_t));
+	task = kmalloc(sizeof(wl_task_t), GFP_ATOMIC);
 	if (!task) {
 		WL_ERROR(("wl%d: wl_schedule_task: out of memory\n", wl->pub->unit));
 		return -ENOMEM;
@@ -1911,7 +1911,7 @@ wl_timer_t *wl_init_timer(wl_info_t *wl, void (*fn) (void *arg), void *arg,
 {
 	wl_timer_t *t;
 
-	t = osl_malloc(wl->osh, sizeof(wl_timer_t));
+	t = kmalloc(sizeof(wl_timer_t), GFP_ATOMIC);
 	if (!t) {
 		WL_ERROR(("wl%d: wl_init_timer: out of memory\n", wl->pub->unit));
 		return 0;
@@ -1929,7 +1929,7 @@ wl_timer_t *wl_init_timer(wl_info_t *wl, void (*fn) (void *arg), void *arg,
 	wl->timers = t;
 
 #ifdef BCMDBG
-	t->name = osl_malloc(wl->osh, strlen(name) + 1);
+	t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
 	if (t->name)
 		strcpy(t->name, name);
 #endif
drivers/staging/brcm80211/sys/wlc_alloc.c +1 -3
index e637e62..feb9a05 100644
@@ -37,11 +37,9 @@ void *wlc_calloc(osl_t *osh, uint unit, uint size)
 {
 	void *item;
 
-	item = MALLOC(osh, size);
+	item = kzalloc(size, GFP_ATOMIC);
 	if (item == NULL)
 		WL_ERROR(("wl%d: %s: out of memory\n", unit, __func__));
-	else
-		bzero((char *)item, size);
 	return item;
 }
 
drivers/staging/brcm80211/sys/wlc_ampdu.c +1 -2
index 26bc9cc..8470baa 100644
@@ -179,12 +179,11 @@ ampdu_info_t *wlc_ampdu_attach(wlc_info_t *wlc)
 	ASSERT(wlc->pub->tunables->ampdunummpdu <= AMPDU_MAX_MPDU);
 	ASSERT(wlc->pub->tunables->ampdunummpdu > 0);
 
-	ampdu = (ampdu_info_t *) MALLOC(wlc->osh, sizeof(ampdu_info_t));
+	ampdu = kzalloc(sizeof(ampdu_info_t), GFP_ATOMIC);
 	if (!ampdu) {
 		WL_ERROR(("wl%d: wlc_ampdu_attach: out of mem\n", wlc->pub->unit));
 		return NULL;
 	}
-	bzero((char *)ampdu, sizeof(ampdu_info_t));
 	ampdu->wlc = wlc;
 
 	for (i = 0; i < AMPDU_MAX_SCB_TID; i++)
drivers/staging/brcm80211/sys/wlc_antsel.c +1 -3
index ee1cefd..e7e7b6d 100644
@@ -94,14 +94,12 @@ antsel_info_t *wlc_antsel_attach(wlc_info_t *wlc, osl_t *osh,
 						  wlc_hw_info_t *wlc_hw) {
 	antsel_info_t *asi;
 
-	asi = (antsel_info_t *) MALLOC(osh, sizeof(antsel_info_t));
+	asi = kzalloc(sizeof(antsel_info_t), GFP_ATOMIC);
 	if (!asi) {
 		WL_ERROR(("wl%d: wlc_antsel_attach: out of mem\n", pub->unit));
 		return NULL;
 	}
 
-	bzero((char *)asi, sizeof(antsel_info_t));
-
 	asi->wlc = wlc;
 	asi->pub = pub;
 	asi->antsel_type = ANTSEL_NA;
drivers/staging/brcm80211/sys/wlc_channel.c +1 -2
index f62144a..b9395d6 100644
@@ -612,12 +612,11 @@ wlc_cm_info_t *wlc_channel_mgr_attach(wlc_info_t *wlc)
 
 	WL_TRACE(("wl%d: wlc_channel_mgr_attach\n", wlc->pub->unit));
 
-	wlc_cm = (wlc_cm_info_t *) MALLOC(pub->osh, sizeof(wlc_cm_info_t));
+	wlc_cm = kzalloc(sizeof(wlc_cm_info_t), GFP_ATOMIC);
 	if (wlc_cm == NULL) {
 		WL_ERROR(("wl%d: %s: out of memory", pub->unit, __func__));
 		return NULL;
 	}
-	bzero((char *)wlc_cm, sizeof(wlc_cm_info_t));
 	wlc_cm->pub = pub;
 	wlc_cm->wlc = wlc;
 	wlc->cmi = wlc_cm;
drivers/staging/brcm80211/sys/wlc_event.c +2 -5
index 4af1e71..549ca0a 100644
@@ -58,12 +58,10 @@ wlc_eventq_t *wlc_eventq_attach(wlc_pub_t *pub, struct wlc_info *wlc, void *wl,
 {
 	wlc_eventq_t *eq;
 
-	eq = (wlc_eventq_t *) MALLOC(pub->osh, sizeof(wlc_eventq_t));
+	eq = kzalloc(sizeof(wlc_eventq_t), GFP_ATOMIC);
 	if (eq == NULL)
 		return NULL;
 
-	bzero(eq, sizeof(wlc_eventq_t));
-
 	eq->cb = cb;
 	eq->wlc = wlc;
 	eq->wl = wl;
@@ -125,12 +123,11 @@ wlc_event_t *wlc_event_alloc(wlc_eventq_t *eq)
 {
 	wlc_event_t *e;
 
-	e = MALLOC(eq->pub->osh, sizeof(wlc_event_t));
+	e = kzalloc(sizeof(wlc_event_t), GFP_ATOMIC);
 
 	if (e == NULL)
 		return NULL;
 
-	bzero(e, sizeof(wlc_event_t));
 	return e;
 }
 
drivers/staging/brcm80211/sys/wlc_phy_shim.c +1 -3
index 37bb593..57acd30 100644
@@ -66,13 +66,11 @@ wlc_phy_shim_info_t *wlc_phy_shim_attach(wlc_hw_info_t *wlc_hw,
 						       void *wl, void *wlc) {
 	wlc_phy_shim_info_t *physhim = NULL;
 
-	physhim = (wlc_phy_shim_info_t *)MALLOC(wlc_hw->osh,
-		sizeof(wlc_phy_shim_info_t));
+	physhim = kzalloc(sizeof(wlc_phy_shim_info_t), GFP_ATOMIC);
 	if (!physhim) {
 		WL_ERROR(("wl%d: wlc_phy_shim_attach: out of mem\n", wlc_hw->unit));
 		return NULL;
 	}
-	bzero((char *)physhim, sizeof(wlc_phy_shim_info_t));
 	physhim->wlc_hw = wlc_hw;
 	physhim->wlc = wlc;
 	physhim->wl = wl;
drivers/staging/brcm80211/util/bcmotp.c +1 -1
index 30ad224..307cb00 100644
@@ -760,7 +760,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len)
 
 	/* Read the whole otp so we can easily manipulate it */
 	lim = hndotp_size(oh);
-	rawotp = MALLOC(si_osh(oi->sih), lim);
+	rawotp = kmalloc(lim, GFP_ATOMIC);
 	if (rawotp == NULL) {
 		rc = -2;
 		goto out;
drivers/staging/brcm80211/util/bcmsrom.c +8 -12
index 13fe173..377831d 100644
@@ -398,7 +398,7 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count)
 
 	boardnum = -1;
 
-	base = MALLOC(osh, MAXSZ_NVRAM_VARS);
+	base = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
 	ASSERT(base != NULL);
 	if (!base)
 		return -2;
@@ -1509,13 +1509,11 @@ static int otp_read_pci(osl_t *osh, si_t *sih, u16 *buf, uint bufsz)
 
 	ASSERT(bufsz <= OTP_SZ_MAX);
 
-	otp = MALLOC(osh, OTP_SZ_MAX);
+	otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC);
 	if (otp == NULL) {
 		return BCME_ERROR;
 	}
 
-	bzero(otp, OTP_SZ_MAX);
-
 	err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz);
 
 	bcopy(otp, buf, bufsz);
@@ -1558,7 +1556,7 @@ static int initvars_table(osl_t *osh, char *start, char *end, char **vars,
 
 	/* do it only when there is more than just the null string */
 	if (c > 1) {
-		char *vp = MALLOC(osh, c);
+		char *vp = kmalloc(c, GFP_ATOMIC);
 		ASSERT(vp != NULL);
 		if (!vp)
 			return BCME_NOMEM;
@@ -1588,7 +1586,7 @@ static int initvars_flash(si_t *sih, osl_t *osh, char **base, uint len)
 	char devpath[SI_DEVPATH_BUFSZ];
 
 	/* allocate memory and read in flash */
-	flash = MALLOC(osh, NVRAM_SPACE);
+	flash = kmalloc(NVRAM_SPACE, GFP_ATOMIC);
 	if (!flash)
 		return BCME_NOMEM;
 	err = nvram_getall(flash, NVRAM_SPACE);
@@ -1645,7 +1643,7 @@ static int initvars_flash_si(si_t *sih, char **vars, uint *count)
 	ASSERT(vars != NULL);
 	ASSERT(count != NULL);
 
-	base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
+	base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
 	ASSERT(vp != NULL);
 	if (!vp)
 		return BCME_NOMEM;
@@ -1859,7 +1857,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
 	 * if we should return an error when CRC fails or read SROM variables
 	 * from flash.
 	 */
-	srom = MALLOC(osh, SROM_MAX);
+	srom = kmalloc(SROM_MAX, GFP_ATOMIC);
 	ASSERT(srom != NULL);
 	if (!srom)
 		return -2;
@@ -1947,7 +1945,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
 	ASSERT(vars != NULL);
 	ASSERT(count != NULL);
 
-	base = vp = MALLOC(osh, MAXSZ_NVRAM_VARS);
+	base = vp = kmalloc(MAXSZ_NVRAM_VARS, GFP_ATOMIC);
 	ASSERT(vp != NULL);
 	if (!vp) {
 		err = -2;
@@ -2000,14 +1998,12 @@ static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count)
 	ASSERT(numfn <= SDIOD_MAX_IOFUNCS);
 
 	for (fn = 0; fn <= numfn; fn++) {
-		cis[fn] = MALLOC(osh, SBSDIO_CIS_SIZE_LIMIT)
+		cis[fn] = kzalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC);
 		if (cis[fn] == NULL) {
 			rc = -1;
 			break;
 		}
 
-		bzero(cis[fn], SBSDIO_CIS_SIZE_LIMIT);
-
 		if (bcmsdh_cis_read(NULL, fn, cis[fn], SBSDIO_CIS_SIZE_LIMIT) !=
 		    0) {
 			MFREE(osh, cis[fn], SBSDIO_CIS_SIZE_LIMIT);
drivers/staging/brcm80211/util/hnddma.c +5 -11
index cb99a23..2d915f0 100644
@@ -378,7 +378,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 	uint size;
 
 	/* allocate private info structure */
-	di = MALLOC(osh, sizeof(dma_info_t));
+	di = kzalloc(sizeof(dma_info_t), GFP_ATOMIC);
 	if (di == NULL) {
 #ifdef BCMDBG
 		printf("dma_attach: out of memory\n");
@@ -386,8 +386,6 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 		return NULL;
 	}
 
-	bzero((char *)di, sizeof(dma_info_t));
-
 	di->msg_level = msg_level ? msg_level : &dma_msg_level;
 
 	/* old chips w/o sb is no longer supported */
@@ -514,23 +512,21 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 	/* allocate tx packet pointer vector */
 	if (ntxd) {
 		size = ntxd * sizeof(void *);
-		di->txp = MALLOC(osh, size);
+		di->txp = kzalloc(size, GFP_ATOMIC);
 		if (di->txp == NULL) {
 			DMA_ERROR(("%s: dma_attach: out of tx memory\n", di->name));
 			goto fail;
 		}
-		bzero((char *)di->txp, size);
 	}
 
 	/* allocate rx packet pointer vector */
 	if (nrxd) {
 		size = nrxd * sizeof(void *);
-		di->rxp = MALLOC(osh, size);
+		di->rxp = kzalloc(size, GFP_ATOMIC);
 		if (di->rxp == NULL) {
 			DMA_ERROR(("%s: dma_attach: out of rx memory\n", di->name));
 			goto fail;
 		}
-		bzero((char *)di->rxp, size);
 	}
 
 	/* allocate transmit descriptor ring, only need ntxd descriptors but it must be aligned */
@@ -562,18 +558,16 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx,
 	if (DMASGLIST_ENAB) {
 		if (ntxd) {
 			size = ntxd * sizeof(hnddma_seg_map_t);
-			di->txp_dmah = (hnddma_seg_map_t *) MALLOC(osh, size);
+			di->txp_dmah = kzalloc(size, GFP_ATOMIC);
 			if (di->txp_dmah == NULL)
 				goto fail;
-			bzero((char *)di->txp_dmah, size);
 		}
 
 		if (nrxd) {
 			size = nrxd * sizeof(hnddma_seg_map_t);
-			di->rxp_dmah = (hnddma_seg_map_t *) MALLOC(osh, size);
+			di->rxp_dmah = kzalloc(size, GFP_ATOMIC);
 			if (di->rxp_dmah == NULL)
 				goto fail;
-			bzero((char *)di->rxp_dmah, size);
 		}
 	}
 
drivers/staging/brcm80211/util/linux_osl.c +0 -20
index 7f4da18..43ac48d 100644
@@ -285,26 +285,6 @@ uint osl_pci_slot(osl_t *osh)
 	return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
 }
 
-void *osl_malloc(osl_t *osh, uint size)
-{
-	void *addr;
-
-	/* only ASSERT if osh is defined */
-	if (osh)
-		ASSERT(osh->magic == OS_HANDLE_MAGIC);
-
-	addr = kmalloc(size, GFP_ATOMIC);
-	if (addr == NULL) {
-		if (osh)
-			osh->failed++;
-		return NULL;
-	}
-	if (osh)
-		osh->malloced += size;
-
-	return addr;
-}
-
 void osl_mfree(osl_t *osh, void *addr, uint size)
 {
 	if (osh) {
drivers/staging/brcm80211/util/nicpci.c +1 -3
index 1c7a21c..d769659 100644
@@ -115,14 +115,12 @@ void *pcicore_init(si_t *sih, osl_t *osh, void *regs)
 	ASSERT(sih->bustype == PCI_BUS);
 
 	/* alloc pcicore_info_t */
-	pi = MALLOC(osh, sizeof(pcicore_info_t));
+	pi = kzalloc(sizeof(pcicore_info_t), GFP_ATOMIC);
 	if (pi == NULL) {
 		PCI_ERROR(("pci_attach: malloc failed!\n"));
 		return NULL;
 	}
 
-	bzero(pi, sizeof(pcicore_info_t));
-
 	pi->sih = sih;
 	pi->osh = osh;
 
drivers/staging/brcm80211/util/nvram/nvram_ro.c +3 -2
index 0127ded..f0470a7 100644
@@ -14,6 +14,7 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/slab.h>
 #include <typedefs.h>
 #include <bcmdefs.h>
 #include <linux/string.h>
@@ -58,7 +59,7 @@ static void get_flash_nvram(si_t *sih, struct nvram_header *nvh)
 	nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
 	bufsz = nvs + VARS_T_OH;
 
-	new = (vars_t *) MALLOC(osh, bufsz);
+	new = kmalloc(bufsz, GFP_ATOMIC);
 	if (new == NULL) {
 		NVR_MSG(("Out of memory for flash vars\n"));
 		return;
@@ -93,7 +94,7 @@ int nvram_append(void *si, char *varlst, uint varsz)
 	uint bufsz = VARS_T_OH;
 	vars_t *new;
 
-	new = MALLOC(si_osh((si_t *) si), bufsz);
+	new = kmalloc(bufsz, GFP_ATOMIC);
 	if (new == NULL)
 		return BCME_NOMEM;
 
drivers/staging/brcm80211/util/siutils.c +1 -1
index ec21dbd..b2423c7 100644
@@ -88,7 +88,7 @@ si_t *si_attach(uint devid, osl_t *osh, void *regs, uint bustype, void *sdh,
 	si_info_t *sii;
 
 	/* alloc si_info_t */
-	sii = MALLOC(osh, sizeof(si_info_t));
+	sii = kmalloc(sizeof(si_info_t), GFP_ATOMIC);
 	if (sii == NULL) {
 		SI_ERROR(("si_attach: malloc failed!\n"));
 		return NULL;
Signature · 1 line
1.6.4.4
#5 lore raw

PATCH 5/7 staging: brcm80211: remove unused NATIVE_{MALLOC,MFREE}

In reply to [email protected]
---
 drivers/staging/brcm80211/include/linux_osl.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/staging/brcm80211/include/linux_osl.h +0 -3
index 69f0e84..0e00188 100644
@@ -97,9 +97,6 @@ typedef struct {
 #define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
 extern void osl_mfree(osl_t *osh, void *addr, uint size);
 
-#define NATIVE_MALLOC(osh, size)	kmalloc(size, GFP_ATOMIC)
-#define NATIVE_MFREE(osh, addr, size)	kfree(addr)
-
 #define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
 extern uint osl_dma_consistent_align(void);
 extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,
Signature · 1 line
1.6.4.4
#6 lore raw

PATCH 6/7 staging: brcm80211: replace MFREE with kfree

In reply to [email protected]
---
 drivers/staging/brcm80211/brcmfmac/bcmsdh.c        |    4 +-
 drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c  |    8 ++--
 drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c  |    4 +-
 .../brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c        |    2 +-
 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c       |    4 +-
 drivers/staging/brcm80211/brcmfmac/dhd_common.c    |   10 ++--
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c     |   16 +++---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c      |   32 ++++++------
 drivers/staging/brcm80211/include/linux_osl.h      |    3 -
 drivers/staging/brcm80211/phy/wlc_phy_cmn.c        |    6 +-
 drivers/staging/brcm80211/phy/wlc_phy_lcn.c        |   10 ++--
 drivers/staging/brcm80211/phy/wlc_phy_n.c          |    6 +-
 drivers/staging/brcm80211/sys/wl_mac80211.c        |   18 ++++----
 drivers/staging/brcm80211/sys/wlc_alloc.c          |   50 +++++++------------
 drivers/staging/brcm80211/sys/wlc_ampdu.c          |    5 +-
 drivers/staging/brcm80211/sys/wlc_antsel.c         |    2 +-
 drivers/staging/brcm80211/sys/wlc_bmac.c           |    2 +-
 drivers/staging/brcm80211/sys/wlc_channel.c        |    2 +-
 drivers/staging/brcm80211/sys/wlc_event.c          |    6 +-
 drivers/staging/brcm80211/sys/wlc_mac80211.c       |   19 +++----
 drivers/staging/brcm80211/sys/wlc_phy_shim.c       |    2 +-
 drivers/staging/brcm80211/util/bcmotp.c            |    2 +-
 drivers/staging/brcm80211/util/bcmsrom.c           |   16 +++---
 drivers/staging/brcm80211/util/hnddma.c            |   12 ++---
 drivers/staging/brcm80211/util/linux_osl.c         |    9 ----
 drivers/staging/brcm80211/util/nicpci.c            |    2 +-
 drivers/staging/brcm80211/util/nvram/nvram_ro.c    |    4 +-
 drivers/staging/brcm80211/util/siutils.c           |    4 +-
 28 files changed, 115 insertions(+), 145 deletions(-)
drivers/staging/brcm80211/brcmfmac/bcmsdh.c +2 -2
index 708575e..bf2aad7 100644
@@ -92,7 +92,7 @@ int bcmsdh_detach(osl_t *osh, void *sdh)
 			sdioh_detach(osh, bcmsdh->sdioh);
 			bcmsdh->sdioh = NULL;
 		}
-		MFREE(osh, bcmsdh, sizeof(bcmsdh_info_t));
+		kfree(bcmsdh);
 	}
 
 	l_bcmsdh = NULL;
@@ -328,7 +328,7 @@ int bcmsdh_cis_read(void *sdh, uint func, u8 * cis, uint length)
 			if ((((tmp_ptr - tmp_buf) + 1) & 0xf) == 0)
 				ptr += sprintf((char *)ptr, "\n");
 		}
-		MFREE(bcmsdh->osh, tmp_buf, length);
+		kfree(tmp_buf);
 	}
 
 	return SDIOH_API_SUCCESS(status) ? 0 : BCME_ERROR;
drivers/staging/brcm80211/brcmfmac/bcmsdh_linux.c +4 -4
index 9be6eb6..47ca271 100644
@@ -246,7 +246,7 @@ err:
 	if (sdhc) {
 		if (sdhc->sdh)
 			bcmsdh_detach(sdhc->osh, sdhc->sdh);
-		MFREE(osh, sdhc, sizeof(bcmsdh_hc_t));
+		kfree(sdhc);
 	}
 	if (osh)
 		osl_detach(osh);
@@ -283,7 +283,7 @@ int bcmsdh_remove(struct device *dev)
 
 	/* release SDIO Host Controller info */
 	osh = sdhc->osh;
-	MFREE(osh, sdhc, sizeof(bcmsdh_hc_t));
+	kfree(sdhc);
 	osl_detach(osh);
 
 #if !defined(BCMLXSDMMC)
@@ -471,7 +471,7 @@ err:
 	if (sdhc->sdh)
 		bcmsdh_detach(sdhc->osh, sdhc->sdh);
 	if (sdhc)
-		MFREE(osh, sdhc, sizeof(bcmsdh_hc_t));
+		kfree(sdhc);
 	if (osh)
 		osl_detach(osh);
 	return -ENODEV;
@@ -506,7 +506,7 @@ static void __devexit bcmsdh_pci_remove(struct pci_dev *pdev)
 
 	/* release SDIO Host Controller info */
 	osh = sdhc->osh;
-	MFREE(osh, sdhc, sizeof(bcmsdh_hc_t));
+	kfree(sdhc);
 	osl_detach(osh);
 }
 #endif				/* BCMLXSDMMC */
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c +2 -2
index c54da99..d591278 100644
@@ -131,7 +131,7 @@ extern sdioh_info_t *sdioh_attach(osl_t *osh, void *bar0, uint irq)
 	sd->osh = osh;
 	if (sdioh_sdmmc_osinit(sd) != 0) {
 		sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__));
-		MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+		kfree(sd);
 		return NULL;
 	}
 
@@ -193,7 +193,7 @@ extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd)
 		/* deregister irq */
 		sdioh_sdmmc_osfree(sd);
 
-		MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+		kfree(sd);
 	}
 	return SDIOH_API_RC_SUCCESS;
 }
drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc_linux.c +1 -1
index 7a80bcf..6ee2f48 100644
@@ -164,7 +164,7 @@ void sdioh_sdmmc_osfree(sdioh_info_t *sd)
 	ASSERT(sd && sd->sdos_info);
 
 	sdos = (struct sdos_info *)sd->sdos_info;
-	MFREE(sd->osh, sdos, sizeof(struct sdos_info));
+	kfree(sdos);
 }
 
 /* Interrupt enable/disable */
drivers/staging/brcm80211/brcmfmac/dhd_cdc.c +2 -2
index 3f8d1fd..2af896d 100644
@@ -427,14 +427,14 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 
 fail:
 	if (cdc != NULL)
-		MFREE(dhd->osh, cdc, sizeof(dhd_prot_t));
+		kfree(cdc);
 	return BCME_NOMEM;
 }
 
 /* ~NOTE~ What if another thread is waiting on the semaphore?  Holding it? */
 void dhd_prot_detach(dhd_pub_t *dhd)
 {
-	MFREE(dhd->osh, dhd->prot, sizeof(dhd_prot_t));
+	kfree(dhd->prot);
 	dhd->prot = NULL;
 }
 
drivers/staging/brcm80211/brcmfmac/dhd_common.c +5 -5
index 0d17ed0..40004f2 100644
@@ -1052,7 +1052,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 
 fail:
 	if (arg_org)
-		MFREE(dhd->osh, arg_org, strlen(arg) + 1);
+		kfree(arg_org);
 }
 
 void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
@@ -1188,10 +1188,10 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 fail:
 	if (arg_org)
-		MFREE(dhd->osh, arg_org, strlen(arg) + 1);
+		kfree(arg_org);
 
 	if (buf)
-		MFREE(dhd->osh, buf, BUF_SIZE);
+		kfree(buf);
 }
 
 void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode)
@@ -1406,7 +1406,7 @@ void dhd_iscan_free_buf(void *dhdp, iscan_buf_t *iscan_delete)
 			iscanbuf_free = iscanbuf_cur;
 			iscanbuf_cur = iscanbuf_cur->next;
 			iscanbuf_free->next = 0;
-			MFREE(dhd->osh, iscanbuf_free, sizeof(iscan_buf_t));
+			kfree(iscanbuf_free);
 		}
 		iscan_chain = 0;
 	} else {
@@ -1420,7 +1420,7 @@ void dhd_iscan_free_buf(void *dhdp, iscan_buf_t *iscan_delete)
 			iscanbuf_prv->next = iscan_delete->next;
 
 		iscan_delete->next = 0;
-		MFREE(dhd->osh, iscan_delete, sizeof(iscan_buf_t));
+		kfree(iscan_delete);
 
 		if (!iscanbuf_prv)
 			iscan_chain = 0;
drivers/staging/brcm80211/brcmfmac/dhd_linux.c +8 -8
index 27106ab..2d2c7ea 100644
@@ -747,7 +747,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 		allmulti = cnt ? true : allmulti;
 	}
 
-	MFREE(dhd->pub.osh, buf, buflen);
+	kfree(buf);
 
 	/* Now send the allmulti setting.  This is based on the setting in the
 	 * net_device flags, but might be modified above to be turned on if we
@@ -768,7 +768,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 		DHD_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
 			"buflen %u\n", dhd_ifname(&dhd->pub, ifidx),
 			(int)sizeof(allmulti), buflen));
-		MFREE(dhd->pub.osh, buf, buflen);
+		kfree(buf);
 		return;
 	}
 
@@ -784,7 +784,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 			   dhd_ifname(&dhd->pub, ifidx), ltoh32(allmulti)));
 	}
 
-	MFREE(dhd->pub.osh, buf, buflen);
+	kfree(buf);
 
 	/* Finally, pick up the PROMISC flag as well, like the NIC
 		 driver does */
@@ -921,7 +921,7 @@ static void dhd_op_if(dhd_if_t *ifp)
 			free_netdev(ifp->net);
 
 		dhd->iflist[ifp->idx] = NULL;
-		MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
+		kfree(ifp);
 #ifdef SOFTAP
 		if (ifp->net == ap_net_dev)
 			ap_net_dev = NULL;	/*  NULL  SOFTAP global
@@ -1742,7 +1742,7 @@ done:
 	}
 
 	if (buf)
-		MFREE(dhd->pub.osh, buf, buflen);
+		kfree(buf);
 
 	return OSL_ERROR(bcmerror);
 }
@@ -2367,8 +2367,8 @@ void dhd_detach(dhd_pub_t *dhdp)
 			WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_LINK_DOWN_TMOUT);
 			WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_PNO_FIND_TMOUT);
 			free_netdev(ifp->net);
-			MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
-			MFREE(dhd->pub.osh, dhd, sizeof(*dhd));
+			kfree(ifp);
+			kfree(dhd);
 		}
 	}
 }
@@ -2916,7 +2916,7 @@ int write_to_file(dhd_pub_t *dhd, u8 *buf, int size)
 
 exit:
 	/* free buf before return */
-	MFREE(dhd->osh, buf, size);
+	kfree(buf);
 	/* close file before return */
 	if (fp)
 		filp_close(fp, current->files);
drivers/staging/brcm80211/brcmfmac/dhd_sdio.c +16 -16
index f9605f9..66837a1 100644
@@ -1927,9 +1927,9 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 
 done:
 	if (mbuffer)
-		MFREE(bus->dhd->osh, mbuffer, msize);
+		kfree(mbuffer);
 	if (str)
-		MFREE(bus->dhd->osh, str, maxstrlen);
+		kfree(str);
 
 	return bcmerror;
 }
@@ -1959,7 +1959,7 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus)
 		if (ret) {
 			printf("%s: Error membytes %d\n", __func__, ret);
 			if (buf)
-				MFREE(bus->dhd->osh, buf, size);
+				kfree(buf);
 			return -1;
 		}
 		printf(".");
@@ -2078,7 +2078,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len)
 
 	/* Free the old ones and replace with passed variables */
 	if (bus->vars)
-		MFREE(bus->dhd->osh, bus->vars, bus->varsz);
+		kfree(bus->vars);
 
 	bus->vars = kmalloc(len, GFP_ATOMIC);
 	bus->varsz = bus->vars ? len : 0;
@@ -2562,10 +2562,10 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 			DHD_ERROR(("%s: Download/Upload/Compare of NVRAM ok.\n",
 				__func__));
 
-		MFREE(bus->dhd->osh, nvram_ularray, varsize);
+		kfree(nvram_ularray);
 #endif				/* DHD_DEBUG */
 
-		MFREE(bus->dhd->osh, vbuffer, varsize);
+		kfree(vbuffer);
 	}
 
 	/* adjust to the user specified RAM */
@@ -5286,7 +5286,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva,
 			if (err) {
 				DHD_INFO(("dhdsdio_probe: fn %d cis read "
 					"err %d\n", fn, err));
-				MFREE(osh, cis[fn], SBSDIO_CIS_SIZE_LIMIT);
+				kfree(cis[fn]);
 				break;
 			}
 			dhd_dump_cis(fn, cis[fn]);
@@ -5294,7 +5294,7 @@ dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva,
 
 		while (fn-- > 0) {
 			ASSERT(cis[fn]);
-			MFREE(osh, cis[fn], SBSDIO_CIS_SIZE_LIMIT);
+			kfree(cis[fn]);
 		}
 
 		if (err) {
@@ -5400,7 +5400,7 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh)
 			   __func__, MAX_DATA_BUF));
 		/* release rxbuf which was already located as above */
 		if (!bus->rxblen)
-			MFREE(osh, bus->rxbuf, bus->rxblen);
+			kfree(bus->rxbuf);
 		goto fail;
 	}
 
@@ -5544,7 +5544,7 @@ static void dhdsdio_release(dhd_bus_t *bus, osl_t *osh)
 
 		dhdsdio_release_malloc(bus, osh);
 
-		MFREE(osh, bus, sizeof(dhd_bus_t));
+		kfree(bus);
 	}
 
 	if (osh)
@@ -5561,13 +5561,13 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh)
 		return;
 
 	if (bus->rxbuf) {
-		MFREE(osh, bus->rxbuf, bus->rxblen);
+		kfree(bus->rxbuf);
 		bus->rxctl = bus->rxbuf = NULL;
 		bus->rxlen = 0;
 	}
 
 	if (bus->databuf) {
-		MFREE(osh, bus->databuf, MAX_DATA_BUF);
+		kfree(bus->databuf);
 		bus->databuf = NULL;
 	}
 }
@@ -5587,7 +5587,7 @@ static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh)
 		dhdsdio_clkctl(bus, CLK_NONE, FALSE);
 		si_detach(bus->sih);
 		if (bus->vars && bus->varsz)
-			MFREE(osh, bus->vars, bus->varsz);
+			kfree(bus->vars);
 		bus->vars = NULL;
 	}
 
@@ -5710,7 +5710,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 			DHD_ERROR(("%s: Download/Upload/Compare succeeded.\n",
 				__func__));
 
-		MFREE(bus->dhd->osh, ularray, bus->ramsize);
+		kfree(ularray);
 	}
 #endif				/* DHD_DEBUG */
 
@@ -5758,7 +5758,7 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path)
 
 err:
 	if (memblock)
-		MFREE(bus->dhd->osh, memblock, MEMBLOCK + DHD_SDALIGN);
+		kfree(memblock);
 
 	if (image)
 		dhd_os_close_image(image);
@@ -5898,7 +5898,7 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus)
 
 err:
 	if (memblock)
-		MFREE(bus->dhd->osh, memblock, MEMBLOCK);
+		kfree(memblock);
 
 	if (image)
 		dhd_os_close_image(image);
drivers/staging/brcm80211/include/linux_osl.h +0 -3
index 0e00188..ec7fc1f 100644
@@ -94,9 +94,6 @@ typedef struct {
 
 #define BUS_SWAP32(v)		(v)
 
-#define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
-extern void osl_mfree(osl_t *osh, void *addr, uint size);
-
 #define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
 extern uint osl_dma_consistent_align(void);
 extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,
drivers/staging/brcm80211/phy/wlc_phy_cmn.c +3 -3
index 739fe71..ac9ff5e 100644
@@ -599,7 +599,7 @@ void wlc_phy_shared_detach(shared_phy_t *phy_sh)
 		if (phy_sh->phy_head) {
 			ASSERT(!phy_sh->phy_head);
 		}
-		MFREE(osh, phy_sh, sizeof(shared_phy_t));
+		kfree(phy_sh);
 	}
 }
 
@@ -780,7 +780,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars
 
  err:
 	if (pi)
-		MFREE(sh->osh, pi, sizeof(phy_info_t));
+		kfree(pi);
 	return NULL;
 }
 
@@ -808,7 +808,7 @@ void wlc_phy_detach(wlc_phy_t *pih)
 		if (pi->pi_fptr.detach)
 			(pi->pi_fptr.detach) (pi);
 
-		MFREE(pi->sh->osh, pi, sizeof(phy_info_t));
+		kfree(pi);
 	}
 }
 
drivers/staging/brcm80211/phy/wlc_phy_lcn.c +5 -5
index 1a70f9a..7b3ff3e 100644
@@ -2061,7 +2061,7 @@ wlc_lcnphy_tx_iqlo_cal(phy_info_t *pi,
 
  cleanup:
 	wlc_lcnphy_tx_iqlo_loopback_cleanup(pi, values_to_save);
-	MFREE(pi->sh->osh, values_to_save, 20 * sizeof(u16));
+	kfree(values_to_save);
 
 	if (!keep_tone)
 		wlc_lcnphy_stop_tx_tone(pi);
@@ -3437,7 +3437,7 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
 	}
 
  cal_done:
-	MFREE(pi->sh->osh, ptr, 131 * sizeof(s16));
+	kfree(ptr);
 	return result;
 }
 
@@ -4212,8 +4212,8 @@ wlc_lcnphy_a1(phy_info_t *pi, int cal_type, int num_levels, int step_size_lg2)
 	write_phy_reg(pi, 0x4d8, phy_c30);
 	write_radio_reg(pi, RADIO_2064_REG026, phy_c31);
 
-	MFREE(pi->sh->osh, phy_c32, 20 * sizeof(u16));
-	MFREE(pi->sh->osh, ptr, 131 * sizeof(s16));
+	kfree(phy_c32);
+	kfree(ptr);
 }
 
 static void
@@ -5047,7 +5047,7 @@ void wlc_phy_txpower_recalc_target_lcnphy(phy_info_t *pi)
 
 void wlc_phy_detach_lcnphy(phy_info_t *pi)
 {
-	MFREE(pi->sh->osh, pi->u.pi_lcnphy, sizeof(phy_info_lcnphy_t));
+	kfree(pi->u.pi_lcnphy);
 }
 
 bool wlc_phy_attach_lcnphy(phy_info_t *pi)
drivers/staging/brcm80211/phy/wlc_phy_n.c +3 -3
index 529e06c..b0ae73e 100644
@@ -22382,7 +22382,7 @@ wlc_phy_gen_load_samples_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val,
 	wlc_phy_loadsampletable_nphy(pi, tone_buf, num_samps);
 
 	if (tone_buf != NULL)
-		MFREE(pi->sh->osh, tone_buf, sizeof(cs32) * tbl_len);
+		kfree(tone_buf);
 
 	return num_samps;
 }
@@ -22430,7 +22430,7 @@ wlc_phy_loadsampletable_nphy(phy_info_t *pi, cs32 *tone_buf,
 				 data_buf);
 
 	if (data_buf != NULL)
-		MFREE(pi->sh->osh, data_buf, sizeof(u32) * num_samps);
+		kfree(data_buf);
 
 	if (pi->phyhang_avoid)
 		wlc_phy_stay_in_carriersearch_nphy(pi, FALSE);
@@ -26768,7 +26768,7 @@ wlc_phy_a1_nphy(phy_info_t *pi, u8 core, u32 winsz, u32 start,
 				  PHY_CORE_0) ? NPHY_TBL_ID_EPSILONTBL0 :
 				 NPHY_TBL_ID_EPSILONTBL1, sz, start, 32, dst);
 
-	MFREE(pi->sh->osh, buf, 2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE);
+	kfree(buf);
 }
 
 static void
drivers/staging/brcm80211/sys/wl_mac80211.c +9 -9
index bcd6e69..ee19502 100644
@@ -1582,9 +1582,9 @@ void wl_free(wl_info_t *wl)
 		next = t->next;
 #ifdef BCMDBG
 		if (t->name)
-			MFREE(wl->osh, t->name, strlen(t->name) + 1);
+			kfree(t->name);
 #endif
-		MFREE(wl->osh, t, sizeof(wl_timer_t));
+		kfree(t);
 	}
 
 	osh = wl->osh;
@@ -1668,7 +1668,7 @@ wl_schedule_task(wl_info_t *wl, void (*fn) (struct wl_task *task),
 
 	if (!schedule_work(&task->work)) {
 		WL_ERROR(("wl%d: schedule_work() failed\n", wl->pub->unit));
-		MFREE(wl->osh, task, sizeof(wl_task_t));
+		kfree(task);
 		return -ENOMEM;
 	}
 
@@ -1984,9 +1984,9 @@ void wl_free_timer(wl_info_t *wl, wl_timer_t *t)
 		wl->timers = wl->timers->next;
 #ifdef BCMDBG
 		if (t->name)
-			MFREE(wl->osh, t->name, strlen(t->name) + 1);
+			kfree(t->name);
 #endif
-		MFREE(wl->osh, t, sizeof(wl_timer_t));
+		kfree(t);
 		return;
 
 	}
@@ -1997,9 +1997,9 @@ void wl_free_timer(wl_info_t *wl, wl_timer_t *t)
 			tmp->next = t->next;
 #ifdef BCMDBG
 			if (t->name)
-				MFREE(wl->osh, t->name, strlen(t->name) + 1);
+				kfree(t->name);
 #endif
-			MFREE(wl->osh, t, sizeof(wl_timer_t));
+			kfree(t);
 			return;
 		}
 		tmp = tmp->next;
@@ -2199,7 +2199,7 @@ static void wl_rpcq_dispatch(struct wl_task *task)
 
 	RPCQ_UNLOCK(wl, flags);
 
-	MFREE(wl->osh, task, sizeof(wl_task_t));
+	kfree(task);
 	atomic_dec(&wl->callbacks);
 }
 
@@ -2259,7 +2259,7 @@ static void wl_timer_task(wl_task_t *task)
 	wl_timer_t *t = (wl_timer_t *) task->context;
 
 	_wl_timer(t);
-	MFREE(t->wl->osh, task, sizeof(wl_task_t));
+	kfree(task);
 
 	/* This dec is for the task_schedule. The timer related
 	 * callback is decremented in _wl_timer
drivers/staging/brcm80211/sys/wlc_alloc.c +19 -31

122 lines not on this page · raw message

drivers/staging/brcm80211/sys/wlc_ampdu.c +2 -3
index 8470baa..7f22c81 100644
@@ -242,13 +242,12 @@ void wlc_ampdu_detach(ampdu_info_t *ampdu)
 	/* free all ini's which were to be freed on callbacks which were never called */
 	for (i = 0; i < AMPDU_INI_FREE; i++) {
 		if (ampdu->ini_free[i]) {
-			MFREE(ampdu->wlc->osh, ampdu->ini_free[i],
-			      sizeof(scb_ampdu_tid_ini_t));
+			kfree(ampdu->ini_free[i]);
 		}
 	}
 
 	wlc_module_unregister(ampdu->wlc->pub, "ampdu", ampdu);
-	MFREE(ampdu->wlc->osh, ampdu, sizeof(ampdu_info_t));
+	kfree(ampdu);
 }
 
 void scb_ampdu_cleanup(ampdu_info_t *ampdu, struct scb *scb)
drivers/staging/brcm80211/sys/wlc_antsel.c +1 -1
index e7e7b6d..fafef13 100644
@@ -158,7 +158,7 @@ void wlc_antsel_detach(antsel_info_t *asi)
 	if (!asi)
 		return;
 
-	MFREE(asi->pub->osh, asi, sizeof(antsel_info_t));
+	kfree(asi);
 }
 
 void wlc_antsel_init(antsel_info_t *asi)
drivers/staging/brcm80211/sys/wlc_bmac.c +1 -1
index afbbfad..9544258 100644
@@ -1106,7 +1106,7 @@ int wlc_bmac_detach(wlc_info_t *wlc)
 
 	/* free vars */
 	if (wlc_hw->vars) {
-		MFREE(wlc_hw->osh, wlc_hw->vars, wlc_hw->vars_size);
+		kfree(wlc_hw->vars);
 		wlc_hw->vars = NULL;
 	}
 
drivers/staging/brcm80211/sys/wlc_channel.c +1 -1
index b9395d6..a3de0e2 100644
@@ -650,7 +650,7 @@ wlc_cm_info_t *wlc_channel_mgr_attach(wlc_info_t *wlc)
 void wlc_channel_mgr_detach(wlc_cm_info_t *wlc_cm)
 {
 	if (wlc_cm)
-		MFREE(wlc_cm->pub->osh, wlc_cm, sizeof(wlc_cm_info_t));
+		kfree(wlc_cm);
 }
 
 const char *wlc_channel_country_abbrev(wlc_cm_info_t *wlc_cm)
drivers/staging/brcm80211/sys/wlc_event.c +3 -3
index 549ca0a..91a57e0 100644
@@ -71,7 +71,7 @@ wlc_eventq_t *wlc_eventq_attach(wlc_pub_t *pub, struct wlc_info *wlc, void *wl,
 	if (!eq->timer) {
 		WL_ERROR(("wl%d: wlc_eventq_attach: timer failed\n",
 			  pub->unit));
-		MFREE(eq->pub->osh, eq, sizeof(wlc_eventq_t));
+		kfree(eq);
 		return NULL;
 	}
 
@@ -93,7 +93,7 @@ int wlc_eventq_detach(wlc_eventq_t *eq)
 	}
 
 	ASSERT(wlc_eventq_avail(eq) == FALSE);
-	MFREE(eq->pub->osh, eq, sizeof(wlc_eventq_t));
+	kfree(eq);
 	return 0;
 }
 
@@ -135,7 +135,7 @@ void wlc_event_free(wlc_eventq_t *eq, wlc_event_t *e)
 {
 	ASSERT(e->data == NULL);
 	ASSERT(e->next == NULL);
-	MFREE(eq->pub->osh, e, sizeof(wlc_event_t));
+	kfree(e);
 }
 
 void wlc_eventq_enq(wlc_eventq_t *eq, wlc_event_t *e)
drivers/staging/brcm80211/sys/wlc_mac80211.c +8 -11
index 464bd63..ee14c82 100644
@@ -2249,8 +2249,7 @@ int wlc_bmac_detach(wlc_info_t *wlc)
 
 	for (idx = 0; idx < MAXBANDS; idx++)
 		if (wlc->bandstate[idx]->pi) {
-			osl_mfree(wlc->osh, wlc->bandstate[idx]->pi,
-				  sizeof(wlc_phy_t));
+			kfree(wlc->bandstate[idx]->pi);
 			wlc->bandstate[idx]->pi = NULL;
 		}
 
@@ -2337,15 +2336,14 @@ uint wlc_detach(wlc_info_t *wlc)
 	 * references the wlc->hw->vars which is freed in wlc_bmac_detach()
 	 */
 	if (wlc->pub->vars) {
-		osl_mfree(wlc->osh, wlc->pub->vars, wlc->vars_size);
+		kfree(wlc->pub->vars);
 		wlc->pub->vars = NULL;
 	}
 #endif
 
 #ifdef BCMDBG
 	if (wlc->country_ie_override) {
-		osl_mfree(wlc->osh, wlc->country_ie_override,
-			  wlc->country_ie_override->len + TLV_HDR_LEN);
+		kfree(wlc->country_ie_override);
 		wlc->country_ie_override = NULL;
 	}
 #endif				/* BCMDBG */
@@ -2356,7 +2354,7 @@ uint wlc_detach(wlc_info_t *wlc)
 		prev = ptr = wlc->dumpcb_head;
 		while (ptr) {
 			ptr = prev->next;
-			osl_mfree(wlc->osh, prev, sizeof(dumpcb_t));
+			kfree(prev);
 			prev = ptr;
 		}
 		wlc->dumpcb_head = NULL;
@@ -7191,10 +7189,9 @@ void wlc_bss_list_free(wlc_info_t *wlc, wlc_bss_list_t *bss_list)
 		bi = bss_list->ptrs[index];
 		if (bi) {
 			if (bi->bcn_prb) {
-				osl_mfree(wlc->osh, bi->bcn_prb,
-					  bi->bcn_prb_len);
+				kfree(bi->bcn_prb);
 			}
-			osl_mfree(wlc->osh, bi, sizeof(wlc_bss_info_t));
+			kfree(bi);
 			bss_list->ptrs[index] = NULL;
 		}
 	}
@@ -8179,7 +8176,7 @@ static void wlc_process_eventq(void *arg)
 		/* Perform OS specific event processing */
 		wl_event(wlc->wl, etmp->event.ifname, etmp);
 		if (etmp->data) {
-			osl_mfree(wlc->osh, etmp->data, etmp->event.datalen);
+			kfree(etmp->data);
 			etmp->data = NULL;
 		}
 		wlc_event_free(wlc->eventq, etmp);
@@ -8677,5 +8674,5 @@ static void wlc_txq_free(wlc_info_t *wlc, osl_t *osh, wlc_txq_info_t *qi)
 			p->next = p->next->next;
 	}
 
-	osl_mfree(osh, qi, sizeof(wlc_txq_info_t));
+	kfree(qi);
 }
drivers/staging/brcm80211/sys/wlc_phy_shim.c +1 -1
index 57acd30..6980935 100644
@@ -83,7 +83,7 @@ void wlc_phy_shim_detach(wlc_phy_shim_info_t *physhim)
 	if (!physhim)
 		return;
 
-	MFREE(physhim->wlc_hw->osh, physhim, sizeof(wlc_phy_shim_info_t));
+	kfree(physhim);
 }
 
 struct wlapi_timer *wlapi_init_timer(wlc_phy_shim_info_t *physhim,
drivers/staging/brcm80211/util/bcmotp.c +1 -1
index 307cb00..d7c6fc3 100644
@@ -842,7 +842,7 @@ static int hndotp_nvread(void *oh, char *data, uint *len)
 
  out:
 	if (rawotp)
-		MFREE(si_osh(oi->sih), rawotp, lim);
+		kfree(rawotp);
 	si_setcoreidx(oi->sih, idx);
 
 	return rc;
drivers/staging/brcm80211/util/bcmsrom.c +8 -8
index 377831d..3985fbe 100644
@@ -1399,7 +1399,7 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count)
 	ASSERT(b.buf - base <= MAXSZ_NVRAM_VARS);
 	err = initvars_table(osh, base, b.buf, vars, count);
 
-	MFREE(osh, base, MAXSZ_NVRAM_VARS);
+	kfree(base);
 	return err;
 }
 
@@ -1519,7 +1519,7 @@ static int otp_read_pci(osl_t *osh, si_t *sih, u16 *buf, uint bufsz)
 	bcopy(otp, buf, bufsz);
 
 	if (otp)
-		MFREE(osh, otp, OTP_SZ_MAX);
+		kfree(otp);
 
 	/* Check CRC */
 	if (buf[0] == 0xffff) {
@@ -1626,7 +1626,7 @@ static int initvars_flash(si_t *sih, osl_t *osh, char **base, uint len)
 
 	*base = vp;
 
- exit:	MFREE(osh, flash, NVRAM_SPACE);
+ exit:	kfree(flash);
 	return err;
 }
 
@@ -1652,7 +1652,7 @@ static int initvars_flash_si(si_t *sih, char **vars, uint *count)
 	if (err == 0)
 		err = initvars_table(osh, base, vp, vars, count);
 
-	MFREE(osh, base, MAXSZ_NVRAM_VARS);
+	kfree(base);
 
 	return err;
 }
@@ -1977,9 +1977,9 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count)
 
  errout:
 	if (base)
-		MFREE(osh, base, MAXSZ_NVRAM_VARS);
+		kfree(base);
 
-	MFREE(osh, srom, SROM_MAX);
+	kfree(srom);
 	return err;
 }
 
@@ -2006,7 +2006,7 @@ static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count)
 
 		if (bcmsdh_cis_read(NULL, fn, cis[fn], SBSDIO_CIS_SIZE_LIMIT) !=
 		    0) {
-			MFREE(osh, cis[fn], SBSDIO_CIS_SIZE_LIMIT);
+			kfree(cis[fn]);
 			rc = -2;
 			break;
 		}
@@ -2016,7 +2016,7 @@ static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count)
 		rc = srom_parsecis(osh, cis, fn, vars, count);
 
 	while (fn-- > 0)
-		MFREE(osh, cis[fn], SBSDIO_CIS_SIZE_LIMIT);
+		kfree(cis[fn]);
 
 	return rc;
 }
drivers/staging/brcm80211/util/hnddma.c +5 -7
index 2d915f0..c6a8206 100644
@@ -722,22 +722,20 @@ static void _dma_detach(dma_info_t *di)
 
 	/* free packet pointer vectors */
 	if (di->txp)
-		MFREE(di->osh, (void *)di->txp, (di->ntxd * sizeof(void *)));
+		kfree((void *)di->txp);
 	if (di->rxp)
-		MFREE(di->osh, (void *)di->rxp, (di->nrxd * sizeof(void *)));
+		kfree((void *)di->rxp);
 
 	/* free tx packet DMA handles */
 	if (di->txp_dmah)
-		MFREE(di->osh, (void *)di->txp_dmah,
-		      di->ntxd * sizeof(hnddma_seg_map_t));
+		kfree(di->txp_dmah);
 
 	/* free rx packet DMA handles */
 	if (di->rxp_dmah)
-		MFREE(di->osh, (void *)di->rxp_dmah,
-		      di->nrxd * sizeof(hnddma_seg_map_t));
+		kfree(di->rxp_dmah);
 
 	/* free our private info structure */
-	MFREE(di->osh, (void *)di, sizeof(dma_info_t));
+	kfree((void *)di);
 
 }
 
drivers/staging/brcm80211/util/linux_osl.c +0 -9
index 43ac48d..876d72f 100644
@@ -285,15 +285,6 @@ uint osl_pci_slot(osl_t *osh)
 	return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn);
 }
 
-void osl_mfree(osl_t *osh, void *addr, uint size)
-{
-	if (osh) {
-		ASSERT(osh->magic == OS_HANDLE_MAGIC);
-		osh->malloced -= size;
-	}
-	kfree(addr);
-}
-
 uint osl_dma_consistent_align(void)
 {
 	return PAGE_SIZE;
drivers/staging/brcm80211/util/nicpci.c +1 -1
index d769659..c1e26d9 100644
@@ -144,7 +144,7 @@ void pcicore_deinit(void *pch)
 
 	if (pi == NULL)
 		return;
-	MFREE(pi->osh, pi, sizeof(pcicore_info_t));
+	kfree(pi);
 }
 
 /* return cap_offset if requested capability exists in the PCI config space */
drivers/staging/brcm80211/util/nvram/nvram_ro.c +2 -2
index f0470a7..7c5f88d 100644
@@ -116,11 +116,11 @@ void nvram_exit(void *si)
 	this = vars;
 
 	if (this)
-		MFREE(si_osh(sih), this->vars, this->size);
+		kfree(this->vars);
 
 	while (this) {
 		next = this->next;
-		MFREE(si_osh(sih), this, this->bufsz);
+		kfree(this);
 		this = next;
 	}
 	vars = NULL;
drivers/staging/brcm80211/util/siutils.c +2 -2
index b2423c7..906cae4 100644
@@ -96,7 +96,7 @@ si_t *si_attach(uint devid, osl_t *osh, void *regs, uint bustype, void *sdh,
 
 	if (si_doattach(sii, devid, osh, regs, bustype, sdh, vars, varsz) ==
 	    NULL) {
-		MFREE(osh, sii, sizeof(si_info_t));
+		kfree(sii);
 		return NULL;
 	}
 	sii->vars = vars ? *vars : NULL;
@@ -728,7 +728,7 @@ void si_detach(si_t *sih)
 #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS)
 	if (sii != &ksii)
 #endif				/* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */
-		MFREE(sii->osh, sii, sizeof(si_info_t));
+		kfree(sii);
 }
 
 void *si_osh(si_t *sih)
Signature · 1 line
1.6.4.4
#7 lore raw

PATCH 7/7 staging: brcm80211: remove unrefrenced malloced field

In reply to [email protected]

from 'struct osl_info' structure

---
 drivers/staging/brcm80211/util/linux_osl.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/brcm80211/util/linux_osl.c +0 -2
index 876d72f..d86afba 100644
@@ -37,7 +37,6 @@ struct osl_info {
 	osl_pubinfo_t pub;
 	uint magic;
 	void *pdev;
-	uint malloced;
 	uint failed;
 	uint bustype;
 };
@@ -128,7 +127,6 @@ osl_t *osl_attach(void *pdev, uint bustype, bool pkttag)
 #endif /* BRCM_FULLMAC */
 
 	osh->magic = OS_HANDLE_MAGIC;
-	osh->malloced = 0;
 	osh->failed = 0;
 	osh->pdev = pdev;
 	osh->pub.pkttag = pkttag;
Signature · 1 line
1.6.4.4
#8 lore raw
In reply to [email protected]
Quoted 6 lines · On Wed, Oct 13, 2010 at 12:09:06AM +0200, [email protected] wrote:

These patches replace part of proprietary utility functions with public kernel versions.

The following changes since commit 0f0881b09078fe3a6bc70f05e8ba49a52b2478a2:
Greg Kroah-Hartman (1):
Staging: brcm80211: remove TRUE #define

All queued up now, thanks.

greg k-h