]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: wilc1000: refactor wilc_parse_assoc_resp_info()
authorAjay Singh <ajay.kathat@microchip.com>
Thu, 1 Nov 2018 16:45:17 +0000 (16:45 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Nov 2018 14:23:01 +0000 (15:23 +0100)
Refactor wilc_parse_assoc_resp_info() function by removing the use of
get_asoc_status() API. For parsing assoc response use the struct and
avoided the use of offset macros to extract the ies information.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/coreconfigurator.c
drivers/staging/wilc1000/coreconfigurator.h

index 2c77e5aad0d6c7e79331327b0e470a6c3d2eed80..2bd62fd5cbe35169281dc5c60e99cb347762b8d3 100644 (file)
@@ -18,14 +18,6 @@ static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt)
                return mgmt->bssid;
 }
 
-static inline u16 get_asoc_status(u8 *data)
-{
-       u16 asoc_status;
-
-       asoc_status = data[3];
-       return (asoc_status << 8) | data[2];
-}
-
 s32 wilc_parse_network_info(u8 *msg_buffer,
                            struct network_info **ret_network_info)
 {
@@ -116,12 +108,12 @@ s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,
 {
        u8 *ies;
        u16 ies_len;
+       struct assoc_resp *res = (struct assoc_resp *)buffer;
 
-       ret_conn_info->status = get_asoc_status(buffer);
+       ret_conn_info->status = le16_to_cpu(res->status_code);
        if (ret_conn_info->status == WLAN_STATUS_SUCCESS) {
-               ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
-               ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN +
-                                       AID_LEN);
+               ies = &buffer[sizeof(*res)];
+               ies_len = buffer_len - sizeof(*res);
 
                ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL);
                if (!ret_conn_info->resp_ies)
index 0d40c77f2706c2e513fcc1b3d13e72a842d637ef..71a9f27d4b8f5c7d9809318574b0164167ce7428 100644 (file)
 
 #define NUM_RSSI                5
 
-#define CAP_INFO_LEN            2
-#define STATUS_CODE_LEN         2
-#define AID_LEN                 2
-
 #define SET_CFG              0
 #define GET_CFG              1
 
@@ -63,6 +59,12 @@ struct disconnect_info {
        size_t ie_len;
 };
 
+struct assoc_resp {
+       __le16 capab_info;
+       __le16 status_code;
+       __le16 aid;
+} __packed;
+
 s32 wilc_parse_network_info(u8 *msg_buffer,
                            struct network_info **ret_network_info);
 s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len,