[PATCH 3/5] Use k*malloc instead of vmalloc

pontus.fuchs at gmail.com pontus.fuchs at gmail.com
Wed Apr 17 06:19:16 EDT 2013


From: Pontus Fuchs <pontus.fuchs at gmail.com>

These are all small allocations so kmalloc is the way to go.
---
 dxe.c  |   17 +++++------------
 main.c |    5 ++---
 smd.c  |    5 ++---
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/dxe.c b/dxe.c
index b05cfdc..74ec43e 100644
--- a/dxe.c
+++ b/dxe.c
@@ -19,7 +19,6 @@
 // through low channels data packets are transfered
 // through high channels managment packets are transfered
 
-#include <linux/vmalloc.h>
 #include <linux/interrupt.h>
 #include "dxe.h"
 #include "txrx.h"
@@ -70,7 +69,7 @@ static int wcn36xx_dxe_allocate_ctl_block(struct wcn36xx_dxe_ch *ch)
 	int i;
 	for (i = 0; i < ch->desc_num; i++)
 	{
-		cur_dxe_ctl = vmalloc(sizeof(*cur_dxe_ctl));
+		cur_dxe_ctl = kmalloc(sizeof(*cur_dxe_ctl), GFP_KERNEL);
 		if (!cur_dxe_ctl) {
 			return -ENOMEM;
 		}
@@ -404,11 +403,8 @@ int wcn36xx_dxe_allocate_mem_pools(struct wcn36xx *wcn)
 		(void**)&wcn->mgmt_mem_pool.phy_addr);
 
 	wcn->mgmt_mem_pool.bitmap =
-		vmalloc((WCN36XX_DXE_CH_DESC_NUMB_TX_H / 32 + 1) *
-		sizeof(u32));
-	memset(wcn->mgmt_mem_pool.bitmap, 0,
-		(WCN36XX_DXE_CH_DESC_NUMB_TX_H / 32 + 1) *
-		sizeof(u32));
+		kzalloc((WCN36XX_DXE_CH_DESC_NUMB_TX_H / 32 + 1) *
+		sizeof(u32), GFP_KERNEL);
 
 	/* Allocate BD headers for DATA frames */
 
@@ -420,11 +416,8 @@ int wcn36xx_dxe_allocate_mem_pools(struct wcn36xx *wcn)
 		(void**)&wcn->data_mem_pool.phy_addr);
 
 	wcn->data_mem_pool.bitmap =
-		vmalloc((WCN36XX_DXE_CH_DESC_NUMB_TX_L / 32 + 1) *
-		sizeof(u32));
-	memset(wcn->data_mem_pool.bitmap, 0,
-		(WCN36XX_DXE_CH_DESC_NUMB_TX_L / 32 + 1) *
-		sizeof(int));
+		kzalloc((WCN36XX_DXE_CH_DESC_NUMB_TX_L / 32 + 1) *
+		sizeof(u32), GFP_KERNEL);
 	return 0;
 }
 int wcn36xx_dxe_tx(struct wcn36xx *wcn, struct sk_buff *skb, u8 broadcast)
diff --git a/main.c b/main.c
index 6547a64..f3d7bf1 100644
--- a/main.c
+++ b/main.c
@@ -18,7 +18,6 @@
 #include <linux/qcomwlan_pwrif.h>
 #include <linux/platform_device.h>
 #include <linux/wcnss_wlan.h>
-#include <linux/vmalloc.h>
 #include <linux/etherdevice.h>
 #include "wcn36xx.h"
 #include "dxe.h"
@@ -60,7 +59,7 @@ static int wcn36xx_start(struct ieee80211_hw *hw)
 		wcn36xx_error("request FM %d", ret);
 	}
 	// maximu SMD message size is 4k
-	wcn->smd_buf = vmalloc(4096);
+	wcn->smd_buf = kmalloc(4096, GFP_KERNEL);
 
 	//TODO pass configuration to FW
 	wcn36xx_smd_load_nv(wcn);
@@ -80,7 +79,7 @@ static void wcn36xx_stop(struct ieee80211_hw *hw)
 
 	wcn36xx_smd_close(wcn);
 
-	vfree(wcn->smd_buf);
+	kfree(wcn->smd_buf);
 }
 
 static void wcn36xx_remove_interface(struct ieee80211_hw *hw,
diff --git a/smd.c b/smd.c
index ea374a0..8719db7 100644
--- a/smd.c
+++ b/smd.c
@@ -14,7 +14,6 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <linux/vmalloc.h>
 #include "smd.h"
 
 int wcn36xx_smd_send_and_wait(struct wcn36xx *wcn, size_t len)
@@ -471,7 +470,7 @@ static void wcn36xx_smd_work(struct work_struct *work)
 			complete(&wcn->smd_compl);
 			return;
 		}
-		msg = vmalloc(msg_len);
+		msg = kmalloc(msg_len, GFP_KERNEL);
 		if (NULL == msg) {
 			complete(&wcn->smd_compl);
 			return;
@@ -482,7 +481,7 @@ static void wcn36xx_smd_work(struct work_struct *work)
 			return;
 		}
 		wcn36xx_smd_rsp_process(msg, msg_len);
-		vfree(msg);
+		kfree(msg);
 	}
 }
 
-- 
1.7.10.4




More information about the wcn36xx mailing list