staging: wilc1000: fixes braces {} are not necessary for single statement blocks
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / host_interface.c
index 930dcba665e52e0004a8ab1fe5ad255a672e264f..47064fe30f853402321dedc357b833aa7f481917 100644 (file)
@@ -7,6 +7,7 @@
 #include "wilc_wlan_if.h"
 #include "wilc_msgqueue.h"
 #include <linux/etherdevice.h>
+#include "wilc_wfi_netdevice.h"
 
 extern u8 connecting;
 
@@ -331,7 +332,7 @@ static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
 
        strWID.id = (u16)WID_CURRENT_CHANNEL;
        strWID.type = WID_CHAR;
-       strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
+       strWID.val = (char *)&pstrHostIFSetChan->set_ch;
        strWID.size = sizeof(char);
 
        PRINT_D(HOSTINF_DBG, "Setting channel\n");
@@ -355,7 +356,7 @@ static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
 
        strWID.id = (u16)WID_SET_DRV_HANDLER;
        strWID.type = WID_INT;
-       strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
+       strWID.val = (s8 *)&pstrHostIfSetDrvHandler->u32Address;
        strWID.size = sizeof(u32);
 
        result = send_config_pkt(SET_CFG, &strWID, 1,
@@ -380,7 +381,7 @@ static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
 
        strWID.id = (u16)WID_SET_OPERATION_MODE;
        strWID.type = WID_INT;
-       strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
+       strWID.val = (s8 *)&pstrHostIfSetOperationMode->u32Mode;
        strWID.size = sizeof(u32);
 
        result = send_config_pkt(SET_CFG, &strWID, 1,
@@ -880,7 +881,7 @@ static s32 Handle_Scan(struct host_if_drv *hif_drv,
        strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
        strWIDList[u32WidsCount].type = WID_CHAR;
        strWIDList[u32WidsCount].size = sizeof(char);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
        u32WidsCount++;
 
        strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
@@ -903,7 +904,7 @@ static s32 Handle_Scan(struct host_if_drv *hif_drv,
        strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
        strWIDList[u32WidsCount].type = WID_CHAR;
        strWIDList[u32WidsCount].size = sizeof(char);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
        u32WidsCount++;
 
        if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
@@ -1068,7 +1069,7 @@ static s32 Handle_Connect(struct host_if_drv *hif_drv,
        strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
        strWIDList[u32WidsCount].type = WID_CHAR;
        strWIDList[u32WidsCount].size = sizeof(char);
-       strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
+       strWIDList[u32WidsCount].val = (s8 *)&hif_drv->strWILC_UsrConnReq.u8security;
        u32WidsCount++;
 
        if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
@@ -1731,21 +1732,21 @@ static int Handle_Key(struct host_if_drv *hif_drv,
                if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
 
                        PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
-                       PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
+                       PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
                        strWIDList[0].id = (u16)WID_11I_MODE;
                        strWIDList[0].type = WID_CHAR;
                        strWIDList[0].size = sizeof(char);
-                       strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
+                       strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
 
                        strWIDList[1].id = WID_AUTH_TYPE;
                        strWIDList[1].type = WID_CHAR;
                        strWIDList[1].size = sizeof(char);
-                       strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
+                       strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
 
                        strWIDList[2].id = (u16)WID_KEY_ID;
                        strWIDList[2].type = WID_CHAR;
 
-                       strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
+                       strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
                        strWIDList[2].size = sizeof(char);
 
                        pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
@@ -1807,7 +1808,7 @@ static int Handle_Key(struct host_if_drv *hif_drv,
                } else {
                        strWID.id = (u16)WID_KEY_ID;
                        strWID.type = WID_CHAR;
-                       strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
+                       strWID.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
                        strWID.size = sizeof(char);
 
                        PRINT_D(HOSTINF_DBG, "Setting default key index\n");
@@ -1838,7 +1839,7 @@ static int Handle_Key(struct host_if_drv *hif_drv,
                        strWIDList[0].id = (u16)WID_11I_MODE;
                        strWIDList[0].type = WID_CHAR;
                        strWIDList[0].size = sizeof(char);
-                       strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
+                       strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
 
                        strWIDList[1].id = (u16)WID_ADD_RX_GTK;
                        strWIDList[1].type = WID_STR;
@@ -1913,7 +1914,7 @@ _WPARxGtk_end_case_:
                        strWIDList[0].id = (u16)WID_11I_MODE;
                        strWIDList[0].type = WID_CHAR;
                        strWIDList[0].size = sizeof(char);
-                       strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
+                       strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
 
                        strWIDList[1].id = (u16)WID_ADD_PTK;
                        strWIDList[1].type = WID_STR;
@@ -2159,9 +2160,7 @@ static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
                result = -EFAULT;
        }
 
-       up(&(hif_drv->hSemGetLINKSPEED));
-
-
+       up(&hif_drv->hSemGetLINKSPEED);
 }
 
 s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
@@ -2172,31 +2171,31 @@ s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatis
        strWIDList[u32WidsCount].id = WID_LINKSPEED;
        strWIDList[u32WidsCount].type = WID_CHAR;
        strWIDList[u32WidsCount].size = sizeof(char);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u8LinkSpeed;
        u32WidsCount++;
 
        strWIDList[u32WidsCount].id = WID_RSSI;
        strWIDList[u32WidsCount].type = WID_CHAR;
        strWIDList[u32WidsCount].size = sizeof(char);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->s8RSSI;
        u32WidsCount++;
 
        strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
        strWIDList[u32WidsCount].type = WID_INT;
        strWIDList[u32WidsCount].size = sizeof(u32);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32TxCount;
        u32WidsCount++;
 
        strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
        strWIDList[u32WidsCount].type = WID_INT;
        strWIDList[u32WidsCount].size = sizeof(u32);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32RxCount;
        u32WidsCount++;
 
        strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
        strWIDList[u32WidsCount].type = WID_INT;
        strWIDList[u32WidsCount].size = sizeof(u32);
-       strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
+       strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->u32TxFailureCount;
        u32WidsCount++;
 
        result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
@@ -2607,8 +2606,8 @@ static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
 
        *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
        *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
-       memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
-
+       memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->u16FrameType,
+              sizeof(u16));
 
        strWID.size = sizeof(u16) + 2;
 
@@ -3340,13 +3339,13 @@ s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
        msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
        memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
 
-       if (pu8RxMic) {
-               memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
-       }
+       if (pu8RxMic)
+               memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic,
+                      RX_MIC_KEY_LEN);
 
-       if (pu8TxMic) {
-               memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
-       }
+       if (pu8TxMic)
+               memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic,
+                      TX_MIC_KEY_LEN);
 
        msg.body.key_info.attr.wpa.index = u8KeyIdx;
        msg.body.key_info.attr.wpa.key_len = u8KeyLen;
@@ -4131,11 +4130,16 @@ void host_int_send_network_info_to_host
 {
 }
 
-s32 host_int_init(struct host_if_drv **hif_drv_handler)
+s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 {
        s32 result = 0;
        struct host_if_drv *hif_drv;
        int err;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
 
@@ -4181,7 +4185,8 @@ s32 host_int_init(struct host_if_drv **hif_drv_handler)
                        goto _fail_;
                }
 
-               hif_thread_handler = kthread_run(hostIFthread, NULL, "WILC_kthread");
+               hif_thread_handler = kthread_run(hostIFthread, wilc,
+                                                "WILC_kthread");
 
                if (IS_ERR(hif_thread_handler)) {
                        PRINT_ER("Failed to creat Thread\n");
@@ -4199,7 +4204,7 @@ s32 host_int_init(struct host_if_drv **hif_drv_handler)
 
        setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
 
-       sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
+       sema_init(&hif_drv->gtOsCfgValuesSem, 1);
        down(&hif_drv->gtOsCfgValuesSem);
 
        hif_drv->enuHostIFstate = HOST_IF_IDLE;
@@ -4250,13 +4255,11 @@ s32 host_int_deinit(struct host_if_drv *hif_drv)
        terminated_handle = hif_drv;
        PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
 
-       if (del_timer_sync(&hif_drv->hScanTimer)) {
+       if (del_timer_sync(&hif_drv->hScanTimer))
                PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
-       }
 
-       if (del_timer_sync(&hif_drv->hConnectTimer)) {
+       if (del_timer_sync(&hif_drv->hConnectTimer))
                PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
-       }
 
        if (del_timer_sync(&periodic_rssi))
                PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
@@ -4295,7 +4298,7 @@ s32 host_int_deinit(struct host_if_drv *hif_drv)
                wilc_mq_destroy(&hif_msg_q);
        }
 
-       down(&(hif_drv->gtOsCfgValuesSem));
+       down(&hif_drv->gtOsCfgValuesSem);
 
        ret = remove_handler_in_list(hif_drv);
        if (ret)
@@ -4836,9 +4839,9 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                pNewJoinBssParam->supp_rates[0] = suppRatesNo;
                                index += 2;
 
-                               for (i = 0; i < suppRatesNo; i++) {
+                               for (i = 0; i < suppRatesNo; i++)
                                        pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
-                               }
+
                                index += suppRatesNo;
                                continue;
                        } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
@@ -4848,9 +4851,9 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                else
                                        pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
                                index += 2;
-                               for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
+                               for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
                                        pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
-                               }
+
                                index += extSuppRatesNo;
                                continue;
                        } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
@@ -4925,9 +4928,9 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
                                rsnIndex += 2;
 
-                               for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
+                               for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
                                        pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
-                               }
+
                                pcipherTotalCount += pcipherCount;
                                rsnIndex += jumpOffset;
 
@@ -4936,9 +4939,9 @@ static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
                                authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
                                rsnIndex += 2;
 
-                               for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
+                               for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
                                        pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
-                               }
+
                                authTotalCount += authCount;
                                rsnIndex += jumpOffset;