From bfaf36a4082a89c53d7632af264656ba2fbb2be9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:17 +0000 Subject: [PATCH] staging: wilc1000: refactor wilc_parse_assoc_resp_info() 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 16 ++++------------ drivers/staging/wilc1000/coreconfigurator.h | 10 ++++++---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 2c77e5aad0d6..2bd62fd5cbe3 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -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) diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 0d40c77f2706..71a9f27d4b8f 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -11,10 +11,6 @@ #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, -- 2.30.2