Skip to contentSkip to conversation

staging: wilc1000: linux_wlan.c: use kzalloc instead of WILC_MALLOC

PATCH In review Chaehyun Lim 4 participants 8 messages Sep 7, 2015 – Sep 9, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 staging: wilc1000: linux_wlan.c: use kzalloc instead of WILC_MALLOC

This patch replaces WILC_MALLOC with kzalloc.

---
 drivers/staging/wilc1000/linux_wlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +1 -2
index afd6702..f7dda75 100644
@@ -2269,8 +2269,7 @@ int wilc_netdev_init(void)
 	sema_init(&close_exit_sync, 0);
 
 	/*create the common structure*/
-	g_linux_wlan = WILC_MALLOC(sizeof(linux_wlan_t));
-	memset(g_linux_wlan, 0, sizeof(linux_wlan_t));
+	g_linux_wlan = kzalloc(sizeof(linux_wlan_t), GFP_KERNEL);
 
 	/*Reset interrupt count debug*/
 	int_rcvdU = 0;
Signature · 1 line
2.5.1
#1 lore raw

PATCH 2/5 staging: wilc1000: linux_wlan.c: add kzalloc error check

This patch adds error check if kzalloc is failed.

---
 drivers/staging/wilc1000/linux_wlan.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/wilc1000/linux_wlan.c +2 -0
index f7dda75..76c48a4 100644
@@ -2270,6 +2270,8 @@ int wilc_netdev_init(void)
 
 	/*create the common structure*/
 	g_linux_wlan = kzalloc(sizeof(linux_wlan_t), GFP_KERNEL);
+	if (!g_linux_wlan)
+		return -ENOMEM;
 
 	/*Reset interrupt count debug*/
 	int_rcvdU = 0;
Signature · 1 line
2.5.1
#2 lore raw

PATCH 3/5 staging: wilc1000: remove commented codes

In reply to Chaehyun Lim

This patch removes commented codes.

---
 drivers/staging/wilc1000/coreconfigurator.c |  7 ---
 drivers/staging/wilc1000/host_interface.c   | 88 -----------------------------
 drivers/staging/wilc1000/linux_mon.c        | 61 --------------------
 drivers/staging/wilc1000/linux_wlan.c       | 28 ---------
 drivers/staging/wilc1000/wilc_sdio.c        |  4 --
 drivers/staging/wilc1000/wilc_wlan.c        |  3 -
 drivers/staging/wilc1000/wilc_wlan_cfg.c    |  3 -
 drivers/staging/wilc1000/wilc_wlan_if.h     |  3 -
 8 files changed, 197 deletions(-)
drivers/staging/wilc1000/coreconfigurator.c +0 -7
index 1889195..f9a46d5 100644
@@ -1463,7 +1463,6 @@ void ProcessBinWid(char *pcPacket, s32 *ps32PktLen,
 		u16MsgLen = (u16)s32ValueSize;
 
 		/* Length */
-		/* pcPacket[s32PktLen++] = (u8)u16MsgLen; */
 		pcPacket[s32PktLen++] = (u8)(u16MsgLen  & 0xFF);
 		pcPacket[s32PktLen++] = (u8)((u16MsgLen >> 8) & 0xFF);
 
@@ -1548,7 +1547,6 @@ s32 further_process_response(u8 *resp,
 
 		cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]);
 		/*Set local copy of WID*/
-		/* pstrWIDresult->ps8WidVal = (s8*)(s32)cfg_sht; */
 		*pu16val = cfg_sht;
 		break;
 	}
@@ -1562,14 +1560,12 @@ s32 further_process_response(u8 *resp,
 				MAKE_WORD16(resp[idx + 2], resp[idx + 3])
 				);
 		/*Set local copy of WID*/
-		/* pstrWIDresult->ps8WidVal = (s8*)cfg_int; */
 		*pu32val = cfg_int;
 		break;
 	}
 
 	case WID_STR:
 		memcpy(cfg_str, resp + idx, cfg_len);
-		/* cfg_str[cfg_len] = '\0'; //mostafa: no need currently for NULL termination */
 		if (pstrWIDresult->s32ValueSize >= cfg_len) {
 			memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */
 			pstrWIDresult->s32ValueSize = cfg_len;
@@ -1863,9 +1859,6 @@ s32 ConfigWaitResponse(char *pcRespBuffer, s32 s32MaxRespBuffLen, s32 *ps32Bytes
 	s32 s32Error = WILC_SUCCESS;
 	/*bug 3878*/
 	/*removed to caller function*/
-	/*gstrConfigPktInfo.pcRespBuffer = pcRespBuffer;
-	 * gstrConfigPktInfo.s32MaxRespBuffLen = s32MaxRespBuffLen;
-	 * gstrConfigPktInfo.bRespRequired = bRespRequired;*/
 
 
 	if (gstrConfigPktInfo.bRespRequired) {
drivers/staging/wilc1000/host_interface.c +0 -88

326 lines not on this page · raw message

drivers/staging/wilc1000/linux_mon.c +0 -61

137 lines not on this page · raw message

drivers/staging/wilc1000/linux_wlan.c +0 -28
index 76c48a4..b9459a5 100644
@@ -640,7 +640,6 @@ static int linux_wlan_rxq_task(void *vp)
 	up(&g_linux_wlan->rxq_thread_started);
 	while (1) {
 		down(&g_linux_wlan->rxq_event);
-		/* wait_for_completion(&g_linux_wlan->rxq_event); */
 
 		if (g_linux_wlan->close) {
 			/*Unlock the mutex in the mac_close function to indicate the exiting of the RX thread */
@@ -680,7 +679,6 @@ static int linux_wlan_txq_task(void *vp)
 
 		PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
 		down(&g_linux_wlan->txq_event);
-		/* wait_for_completion(&pd->txq_event); */
 		PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
 
 		if (g_linux_wlan->close) {
@@ -701,7 +699,6 @@ static int linux_wlan_txq_task(void *vp)
 			ret = g_linux_wlan->oup.wlan_handle_tx_que(&txq_count);
 			if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && netif_queue_stopped(pd->wilc_netdev)*/) {
 				PRINT_D(TX_DBG, "Waking up queue\n");
-				/* netif_wake_queue(pd->wilc_netdev); */
 				if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[0].wilc_netdev))
 					netif_wake_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev);
 				if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[1].wilc_netdev))
@@ -712,8 +709,6 @@ static int linux_wlan_txq_task(void *vp)
 				do {
 					/* Back off from sending packets for some time. */
 					/* schedule_timeout will allow RX task to run and free buffers.*/
-					/* set_current_state(TASK_UNINTERRUPTIBLE); */
-					/* timeout = schedule_timeout(timeout); */
 					msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight);
 				} while (/*timeout*/ 0);
 				backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP;
@@ -909,7 +904,6 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
 	if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0))
 		goto _fail_;
 
-	/* c_val[0] = RATE_AUTO; / * bug 4275: Enable autorate and limit it to 24Mbps * / */
 	c_val[0] = RATE_AUTO;
 	if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
 		goto _fail_;
@@ -1189,8 +1183,6 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic)
 			flush_work(&g_linux_wlan->rx_work_queue);
 
 	#elif (RX_BH_TYPE == RX_BH_KTHREAD)
-		/* if(&nic->rx_sem != NULL) */
-		/* up(&nic->rx_sem); */
 	#endif
 
 		PRINT_D(INIT_DBG, "Deinitializing Threads\n");
@@ -1558,7 +1550,6 @@ int repeat_power_cycle(perInterface_wlan_t *nic)
 
 	sdio_register_driver(&wilc_bus);
 
-	/* msleep(1000); */
 	while (!probe)
 		msleep(100);
 	probe = 0;
@@ -1853,7 +1844,6 @@ int mac_open(struct net_device *ndev)
 	/* Start the network interface queue for this device */
 	PRINT_D(INIT_DBG, "Starting netifQ\n");
 	netif_start_queue(ndev);
-/*	down(&close_exit_sync); */
 	return 0;
 }
 #endif
@@ -2083,7 +2073,6 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
 	struct WILC_WFI_priv *priv;
 	s32 s32Error = WILC_SUCCESS;
 
-	/* struct iwreq *wrq = (struct iwreq *) req;	// tony moved to case SIOCSIWPRIV */
 	#ifdef USE_WIRELESS
 	nic = netdev_priv(ndev);
 
@@ -2189,27 +2178,13 @@ void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
 		if (skb->dev == NULL)
 			PRINT_ER("skb->dev is NULL\n");
 
-		/*
-		 * for(i=0;i<40;i++)
-		 * {
-		 *      if(i<frame_len)
-		 *              WILC_PRINTF("buff_to_send[%d]=%2x\n",i,buff_to_send[i]);
-		 *
-		 * }*/
 
 		/* skb_put(skb, frame_len); */
 		memcpy(skb_put(skb, frame_len), buff_to_send, frame_len);
 
-		/* WILC_PRINTF("After MEM_CPY\n"); */
 
-		/* nic = netdev_priv(wilc_netdev); */
 
 #ifdef USE_WIRELESS
-		/*	if(nic->monitor_flag)
-		 *      {
-		 *              WILC_WFI_monitor_rx(nic->wilc_netdev,skb);
-		 *              return;
-		 *      }*/
 #endif
 		skb->protocol = eth_type_trans(skb, wilc_netdev);
 			#ifndef TCP_ENHANCEMENTS
@@ -2448,12 +2423,9 @@ static void __exit exit_wilc_driver(void)
 
 #ifdef USE_WIRELESS
 #ifdef WILC_AP_EXTERNAL_MLME
-	/* Bug 4600 : WILC_WFI_deinit_mon_interface was already called at mac_close */
-	/* WILC_WFI_deinit_mon_interface(); */
 #endif
 #endif
 
-	/* if(g_linux_wlan->open_ifcs==0) */
 	{
 	#ifndef WILC_SDIO
 		PRINT_D(INIT_DBG, "SPI unregsiter...\n");
drivers/staging/wilc1000/wilc_sdio.c +0 -4
index 5a18148..11371a8 100644
@@ -158,7 +158,6 @@ _fail_:
 static int sdio_clear_int(void)
 {
 #ifndef WILC_SDIO_IRQ_GPIO
-	/* uint32_t sts; */
 	sdio_cmd52_t cmd;
 
 	cmd.read_write = 0;
@@ -732,9 +731,6 @@ static int sdio_read_size(uint32_t *size)
 	g_sdio.sdio_cmd52(&cmd);
 	tmp = cmd.data;
 
-	/* cmd.read_write = 0; */
-	/* cmd.function = 0; */
-	/* cmd.raw = 0; */
 	cmd.address = 0xf3;
 	cmd.data = 0;
 	g_sdio.sdio_cmd52(&cmd);
drivers/staging/wilc1000/wilc_wlan.c +0 -3
index 4b37de5..7e67fee 100644
@@ -911,8 +911,6 @@ static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount)
 		i = 0;
 		sum = 0;
 		do {
-			/* if ((tqe != NULL) && (i < (8)) && */
-			/* if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE-1)) && */
 			if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE - 1)) /* reserve last entry to 0 */) {
 
 				if (tqe->type == WILC_CFG_PKT) {
@@ -1045,7 +1043,6 @@ static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount)
 					 *      Get the entries
 					 **/
 					entries = ((reg >> 3) & 0x3f);
-					/* entries = ((reg>>3)&0x2f); */
 					break;
 				} else {
 					release_bus(RELEASE_ALLOW_SLEEP);
drivers/staging/wilc1000/wilc_wlan_cfg.c +0 -3
index c3f3aaf..6c502ec 100644
@@ -142,7 +142,6 @@ static wilc_cfg_str_t g_cfg_str[] = {
 	{WID_BSSID, g_mac.bssid},	/* 6 bytes */
 	{WID_WEP_KEY_VALUE, g_mac.wep_key},	/* 27 bytes */
 	{WID_11I_PSK, g_mac.i_psk},	/* 65 bytes */
-	/* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */
 	{WID_HARDWARE_VERSION, g_mac.hardwareProductVersion},
 	{WID_MAC_ADDR, g_mac.mac_address},
 	{WID_PHY_VERSION, g_mac.phyversion},
@@ -150,10 +149,8 @@ static wilc_cfg_str_t g_cfg_str[] = {
 	{WID_SUPP_PASSWORD, g_mac.supp_password},
 	{WID_SITE_SURVEY_RESULTS, g_mac.scan_result},
 	{WID_SITE_SURVEY_RESULTS, g_mac.scan_result1},
-	/* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */
 	{WID_ASSOC_REQ_INFO, g_mac.assoc_req},
 	{WID_ASSOC_RES_INFO, g_mac.assoc_rsp},
-	/* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */
 	{WID_FIRMWARE_INFO, g_mac.firmware_version},
 	{WID_IP_ADDRESS, g_mac.ip_address},
 	{WID_NIL, NULL}
drivers/staging/wilc1000/wilc_wlan_if.h +0 -3
index 021a2aa..a4fd8ff 100644
@@ -15,9 +15,6 @@
 #define WILC_AP_EXTERNAL_MLME
 #define WILC_P2P
 #define TCP_ENHANCEMENTS
-/* #define MEMORY_STATIC */
-/* #define WILC_FULLY_HOSTING_AP */
-/* #define USE_OLD_SPI_SW */
 
 
 #include "wilc_oswrapper.h"
Signature · 1 line
2.5.1
#3 lore raw

PATCH 4/5 staging: wilc1000: wilc_msgqueue.c: use kmalloc with GFP_ATOMIC

In reply to Chaehyun Lim

This patch use kmalloc with GFP_ATOMIC instead of WILC_MALLOC. It is inside the spin lock region.

---
 drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_msgqueue.c +1 -1
index 76d2e63..41244ce 100644
@@ -72,7 +72,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 	WILC_NULLCHECK(s32RetStatus, pstrMessage);
 	pstrMessage->u32Length = u32SendBufferSize;
 	pstrMessage->pstrNext = NULL;
-	pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize);
+	pstrMessage->pvBuffer = kmalloc(u32SendBufferSize, GFP_ATOMIC);
 	WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer);
 	memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);
 
Signature · 1 line
2.5.1
#4 lore raw

Re: [PATCH 4/5] staging: wilc1000: wilc_msgqueue.c: use kmalloc with GFP_ATOMIC

Quoted 13 lines · Chaehyun Lim

This patch use kmalloc with GFP_ATOMIC instead of WILC_MALLOC. It is inside the spin lock region.

---
  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/wilc_msgqueue.c +0 -0
index 76d2e63..41244ce 100644

drivers/staging/wilc1000/wilc_msgqueue.c int wilc_mq_send(WILC_MsgQueueHandle *pHandle, · line 77

Quoted 7 lines
drivers/staging/wilc1000/wilc_msgqueue.c +1 -1
@@ -72,7 +72,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
  	WILC_NULLCHECK(s32RetStatus, pstrMessage);
  	pstrMessage->u32Length = u32SendBufferSize;
  	pstrMessage->pstrNext = NULL;
-	pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize);
+	pstrMessage->pvBuffer = kmalloc(u32SendBufferSize, GFP_ATOMIC);
  	WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer);
  	memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);

I want just to let you know this file will be soon changed. Thanks,
Tony.

Quoted 1 line
maintainer
#5 lore raw

Re: [PATCH 4/5] staging: wilc1000: wilc_msgqueue.c: use kmalloc with GFP_ATOMIC

Quoted 11 lines · Tony Cho
Quoted 8 lines · Chaehyun Lim

This patch use kmalloc with GFP_ATOMIC instead of WILC_MALLOC. It is inside the spin lock region.

---
 drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

drivers/staging/wilc1000/wilc_msgqueue.c int wilc_mq_send(WILC_MsgQueueHandle *pHandle, · line 77

Quoted 12 lines
drivers/staging/wilc1000/wilc_msgqueue.c +1 -1
index 76d2e63..41244ce 100644
@@ -72,7 +72,7 @@ int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
 	WILC_NULLCHECK(s32RetStatus, pstrMessage);
 	pstrMessage->u32Length = u32SendBufferSize;
 	pstrMessage->pstrNext = NULL;
-	pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize);
+	pstrMessage->pvBuffer = kmalloc(u32SendBufferSize, GFP_ATOMIC);
 	WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer);
 	memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);

I want just to let you know this file will be soon changed.

That doesn't matter, the first one to submit a change goes "first", everything that comes afterward needs to deal with that. We never tell someone that a patch isn't ok just because at some time in the future something else might change. That drives away developers and was one of the primary reasons other open source kernels have failed in the past.

greg k-h

#6 lore raw

Re: [PATCH 4/5] staging: wilc1000: wilc_msgqueue.c: use kmalloc with GFP_ATOMIC

In reply to Chaehyun Lim
Quoted 5 lines · Chaehyun Lim

This patch use kmalloc with GFP_ATOMIC instead of WILC_MALLOC. It is inside the spin lock region.

---

Its not related to your patch, but while seeing your patch I thought of checking how WILC_NULLCHECK is working. Well, WILC_NULLCHECK is simple, its just checking for NULL and calling WILC_ERRORREPORT. WILC_ERRORREPORT is also simple, it is printing the error and then goto ERRORHANDLER;
Ok, so now there are total 3 ERRORHANDLER label, one in wilc_errorsupport.h, there this label is the part of WILC_CATCH macro, and 2 more ERRORHANDLER in coreconfigurator.c. So it jumps to which ERRORHANDLER ???

regards
sudip

#7 lore raw

PATCH 5/5 staging: wilc1000: host_interface.c: fix build warning

In reply to Chaehyun Lim

This patch remove build build warning from Handle_SetOperationMode function. Host interface operation mode has one of 4 types from AP_MODE, STATION_MODE, GO_MODE and CLIENT_MODE.
This values are range from 0x01 to 0x04 if mode is set correctly. If value of host interface operation is 0, it is not initialized any value because struct tstrHostIFmsg is initialized by zeroes.

---
 drivers/staging/wilc1000/host_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/host_interface.c +1 -1
index e09508e..3be3b4c 100644
@@ -754,7 +754,7 @@ static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOpe
 				 get_id_from_handler(pstrWFIDrv));
 
 
-	if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
+	if (!pstrHostIfSetOperationMode->u32Mode)
 		up(&hSemDeinitDrvHandle);
 
 
Signature · 1 line
2.5.1