Staging: wilc1000: coreconfigurator: Remove trailing whitespace
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / coreconfigurator.c
index 39e463c6f9a8f967ed83ee950b268bbc8d45c834..e10c6ffa698a6f541ad4e40c7007ddc4852b50cd 100644 (file)
@@ -8,14 +8,17 @@
  *  @version   1.0
  */
 
-
 #include "coreconfigurator.h"
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/etherdevice.h>
 #define TAG_PARAM_OFFSET       (MAC_HDR_LEN + TIME_STAMP_LEN + \
                                                        BEACON_INTERVAL_LEN + CAP_INFO_LEN)
+#define ADDR1 4
+#define ADDR2 10
+#define ADDR3 16
 
 /* Basic Frame Type Codes (2-bit) */
 enum basic_frame_type {
@@ -114,7 +117,7 @@ enum info_element_id {
 /* response frame.                                                           */
 static inline u16 get_beacon_period(u8 *data)
 {
-       u16 bcn_per = 0;
+       u16 bcn_per;
 
        bcn_per  = data[0];
        bcn_per |= (data[1] << 8);
@@ -172,38 +175,32 @@ static inline u8 get_from_ds(u8 *header)
        return ((header[1] & 0x02) >> 1);
 }
 
-/* This function extracts the MAC Address in 'address1' field of the MAC     */
-/* header and updates the MAC Address in the allocated 'addr' variable.      */
-static inline void get_address1(u8 *pu8msa, u8 *addr)
-{
-       memcpy(addr, pu8msa + 4, 6);
-}
-
-/* This function extracts the MAC Address in 'address2' field of the MAC     */
-/* header and updates the MAC Address in the allocated 'addr' variable.      */
-static inline void get_address2(u8 *pu8msa, u8 *addr)
-{
-       memcpy(addr, pu8msa + 10, 6);
-}
-
-/* This function extracts the MAC Address in 'address3' field of the MAC     */
-/* header and updates the MAC Address in the allocated 'addr' variable.      */
-static inline void get_address3(u8 *pu8msa, u8 *addr)
-{
-       memcpy(addr, pu8msa + 16, 6);
-}
-
 /* This function extracts the BSSID from the incoming WLAN packet based on   */
-/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr'    */
+/* the 'from ds' bit, and updates the MAC Address in the allocated 'data'    */
 /* variable.                                                                 */
 static inline void get_BSSID(u8 *data, u8 *bssid)
 {
        if (get_from_ds(data) == 1)
-               get_address2(data, bssid);
+               /*
+                * Extract the MAC Address in 'address2' field of the MAC
+                * header and update the MAC Address in the allocated 'data'
+                *  variable.
+                */
+               ether_addr_copy(data, bssid + ADDR2);
        else if (get_to_ds(data) == 1)
-               get_address1(data, bssid);
+               /*
+                * Extract the MAC Address in 'address1' field of the MAC
+                * header and update the MAC Address in the allocated 'data'
+                * variable.
+                */
+               ether_addr_copy(data, bssid + ADDR1);
        else
-               get_address3(data, bssid);
+               /*
+                * Extract the MAC Address in 'address3' field of the MAC
+                * header and update the MAC Address in the allocated 'data'
+                * variable.
+                */
+               ether_addr_copy(data, bssid + ADDR3);
 }
 
 /* This function extracts the SSID from a beacon/probe response frame        */
@@ -256,7 +253,7 @@ static inline u16 get_cap_info(u8 *data)
 /* response frame.                                                                       */
 static inline u16 get_assoc_resp_cap_info(u8 *data)
 {
-       u16 cap_info = 0;
+       u16 cap_info;
 
        cap_info  = data[0];
        cap_info |= (data[1] << 8);
@@ -268,7 +265,7 @@ static inline u16 get_assoc_resp_cap_info(u8 *data)
 /* association response frame and returns association status code            */
 static inline u16 get_asoc_status(u8 *data)
 {
-       u16 asoc_status = 0;
+       u16 asoc_status;
 
        asoc_status = data[3];
        asoc_status = (asoc_status << 8) | data[2];
@@ -280,7 +277,7 @@ static inline u16 get_asoc_status(u8 *data)
 /* response frame                                                                                           */
 static inline u16 get_asoc_id(u8 *data)
 {
-       u16 asoc_id = 0;
+       u16 asoc_id;
 
        asoc_id  = data[4];
        asoc_id |= (data[5] << 8);
@@ -290,7 +287,7 @@ static inline u16 get_asoc_id(u8 *data)
 
 u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset)
 {
-       u16 u16index = 0;
+       u16 u16index;
 
        /*************************************************************************/
        /*                       Beacon Frame - Frame Body                       */
@@ -308,8 +305,7 @@ u8 *get_tim_elm(u8 *pu8msa, u16 u16RxLen, u16 u16TagParamOffset)
        while (u16index < (u16RxLen - FCS_LEN)) {
                if (pu8msa[u16index] == ITIM)
                        return &pu8msa[u16index];
-               else
-                       u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
+               u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
        }
 
        return NULL;
@@ -325,9 +321,8 @@ u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen)
        while (index < (u16RxLen - FCS_LEN)) {
                if (pu8msa[index] == IDSPARMS)
                        return pu8msa[index + 2];
-               else
-                       /* Increment index by length information and header */
-                       index += pu8msa[index + 1] + IE_HDR_LEN;
+               /* Increment index by length information and header */
+               index += pu8msa[index + 1] + IE_HDR_LEN;
        }
 
        /* Return current channel information from the MIB, if beacon/probe  */
@@ -336,13 +331,6 @@ u8 get_current_channel_802_11n(u8 *pu8msa, u16 u16RxLen)
        return 0;  /* no MIB here */
 }
 
-u8 get_current_channel(u8 *pu8msa, u16 u16RxLen)
-{
-       /* Extract current channel information from */
-       /* the beacon/probe response frame          */
-       return get_current_channel_802_11n(pu8msa, u16RxLen);
-}
-
 /**
  *  @brief                      parses the received 'N' message
  *  @details
@@ -425,23 +413,27 @@ s32 parse_network_info(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
                pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((u64)u32Tsf_Hi << 32);
 
                /* Get SSID */
-               get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen));
+               get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &pstrNetworkInfo->u8SsidLen);
 
                /* Get BSSID */
                get_BSSID(pu8msa, pstrNetworkInfo->au8bssid);
 
-               /* Get the current channel */
-               pstrNetworkInfo->u8channel = get_current_channel(pu8msa, (u16RxLen + FCS_LEN));
+               /*
+                * Extract current channel information from
+                * the beacon/probe response frame
+                */
+               pstrNetworkInfo->u8channel = get_current_channel_802_11n(pu8msa,
+                                                       u16RxLen + FCS_LEN);
 
                /* Get beacon period */
-               u8index = (MAC_HDR_LEN + TIME_STAMP_LEN);
+               u8index = MAC_HDR_LEN + TIME_STAMP_LEN;
 
                pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index);
 
                u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
 
                /* Get DTIM Period */
-               pu8TimElm = get_tim_elm(pu8msa, (u16RxLen + FCS_LEN), u8index);
+               pu8TimElm = get_tim_elm(pu8msa, u16RxLen + FCS_LEN, u8index);
                if (pu8TimElm != NULL)
                        pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3];
                pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN];
@@ -544,7 +536,6 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
 
        *ppstrConnectRespInfo = pstrConnectRespInfo;
 
-
        return s32Error;
 }