From: Ajay Singh <ajay.kathat@xxxxxxxxxxxxx> After use of framework API's most of the redundant functions are removed in coreconfigurator.c file. Now moved left over function to host_interface file and deleted the coreconfigurator.c file. Signed-off-by: Ajay Singh <ajay.kathat@xxxxxxxxxxxxx> --- drivers/staging/wilc1000/Makefile | 3 +- drivers/staging/wilc1000/coreconfigurator.c | 126 ---------------------------- drivers/staging/wilc1000/coreconfigurator.h | 4 - drivers/staging/wilc1000/host_interface.c | 117 ++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 132 deletions(-) delete mode 100644 drivers/staging/wilc1000/coreconfigurator.c diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 37e8560..72a4daa 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -5,8 +5,7 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ - coreconfigurator.o host_interface.o \ - wilc_wlan_cfg.o wilc_wlan.o + host_interface.o wilc_wlan_cfg.o wilc_wlan.o obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o wilc1000-sdio-objs += wilc_sdio.o diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c deleted file mode 100644 index 2bd62fd..0000000 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ /dev/null @@ -1,126 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include <net/cfg80211.h> - -#include "coreconfigurator.h" - -static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) -{ - if (ieee80211_has_fromds(mgmt->frame_control)) - return mgmt->sa; - else if (ieee80211_has_tods(mgmt->frame_control)) - return mgmt->da; - else - return mgmt->bssid; -} - -s32 wilc_parse_network_info(u8 *msg_buffer, - struct network_info **ret_network_info) -{ - struct network_info *info; - struct ieee80211_mgmt *mgt; - u8 *wid_val, *msa, *ies; - u16 wid_len, rx_len, ies_len; - u8 msg_type; - size_t offset; - const u8 *ch_elm, *tim_elm, *ssid_elm; - - msg_type = msg_buffer[0]; - if ('N' != msg_type) - return -EFAULT; - - wid_len = get_unaligned_le16(&msg_buffer[6]); - wid_val = &msg_buffer[8]; - - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) - return -ENOMEM; - - info->rssi = wid_val[0]; - - msa = &wid_val[1]; - mgt = (struct ieee80211_mgmt *)&wid_val[1]; - rx_len = wid_len - 1; - - if (ieee80211_is_probe_resp(mgt->frame_control)) { - info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); - info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); - info->tsf_lo = (u32)info->tsf_hi; - offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - } else if (ieee80211_is_beacon(mgt->frame_control)) { - info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); - info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); - info->tsf_lo = (u32)info->tsf_hi; - offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); - } else { - /* only process probe response and beacon frame */ - kfree(info); - return -EIO; - } - - ether_addr_copy(info->bssid, get_bssid(mgt)); - - ies = mgt->u.beacon.variable; - ies_len = rx_len - offset; - if (ies_len <= 0) { - kfree(info); - return -EIO; - } - - info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!info->ies) { - kfree(info); - return -ENOMEM; - } - - info->ies_len = ies_len; - - ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); - if (ssid_elm) { - info->ssid_len = ssid_elm[1]; - if (info->ssid_len <= IEEE80211_MAX_SSID_LEN) - memcpy(info->ssid, ssid_elm + 2, info->ssid_len); - else - info->ssid_len = 0; - } - - ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); - if (ch_elm && ch_elm[1] > 0) - info->ch = ch_elm[2]; - - tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); - if (tim_elm && tim_elm[1] >= 2) - info->dtim_period = tim_elm[3]; - - *ret_network_info = info; - - return 0; -} - -s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, - struct connect_info *ret_conn_info) -{ - u8 *ies; - u16 ies_len; - struct assoc_resp *res = (struct assoc_resp *)buffer; - - ret_conn_info->status = le16_to_cpu(res->status_code); - if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { - 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) - return -ENOMEM; - - ret_conn_info->resp_ies_len = ies_len; - } - - return 0; -} diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index a1347f7..67f6855 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -64,10 +64,6 @@ struct assoc_resp { __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, - struct connect_info *ret_conn_info); void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 01db899..c4f858b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1305,6 +1305,101 @@ static void *host_int_parse_join_bss_param(struct network_info *info) return (void *)param; } +static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) +{ + if (ieee80211_has_fromds(mgmt->frame_control)) + return mgmt->sa; + else if (ieee80211_has_tods(mgmt->frame_control)) + return mgmt->da; + else + return mgmt->bssid; +} + +static s32 wilc_parse_network_info(u8 *msg_buffer, + struct network_info **ret_network_info) +{ + struct network_info *info; + struct ieee80211_mgmt *mgt; + u8 *wid_val, *msa, *ies; + u16 wid_len, rx_len, ies_len; + u8 msg_type; + size_t offset; + const u8 *ch_elm, *tim_elm, *ssid_elm; + + msg_type = msg_buffer[0]; + if ('N' != msg_type) + return -EFAULT; + + wid_len = get_unaligned_le16(&msg_buffer[6]); + wid_val = &msg_buffer[8]; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->rssi = wid_val[0]; + + msa = &wid_val[1]; + mgt = (struct ieee80211_mgmt *)&wid_val[1]; + rx_len = wid_len - 1; + + if (ieee80211_is_probe_resp(mgt->frame_control)) { + info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); + info->tsf_lo = (u32)info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + } else if (ieee80211_is_beacon(mgt->frame_control)) { + info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); + info->tsf_lo = (u32)info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + } else { + /* only process probe response and beacon frame */ + kfree(info); + return -EIO; + } + + ether_addr_copy(info->bssid, get_bssid(mgt)); + + ies = mgt->u.beacon.variable; + ies_len = rx_len - offset; + if (ies_len <= 0) { + kfree(info); + return -EIO; + } + + info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!info->ies) { + kfree(info); + return -ENOMEM; + } + + info->ies_len = ies_len; + + ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); + if (ssid_elm) { + info->ssid_len = ssid_elm[1]; + if (info->ssid_len <= IEEE80211_MAX_SSID_LEN) + memcpy(info->ssid, ssid_elm + 2, info->ssid_len); + else + info->ssid_len = 0; + } + + ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); + if (ch_elm && ch_elm[1] > 0) + info->ch = ch_elm[2]; + + tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); + if (tim_elm && tim_elm[1] >= 2) + info->dtim_period = tim_elm[3]; + + *ret_network_info = info; + + return 0; +} + static void handle_rcvd_ntwrk_info(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -1410,6 +1505,28 @@ static inline void host_int_free_user_conn_req(struct host_if_drv *hif_drv) hif_drv->usr_conn_req.ies = NULL; } +static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, + struct connect_info *ret_conn_info) +{ + u8 *ies; + u16 ies_len; + struct assoc_resp *res = (struct assoc_resp *)buffer; + + ret_conn_info->status = le16_to_cpu(res->status_code); + if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { + 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) + return -ENOMEM; + + ret_conn_info->resp_ies_len = ies_len; + } + + return 0; +} + static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, u8 mac_status) { -- 2.7.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel