From b4ba3b572b469684a3fc804bd2b93fbf848960ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bu=C5=A3iu=20Alexandru=20Octavian?= Date: Fri, 24 Jul 2015 00:13:27 +0300 Subject: [PATCH] drivers: staging: rtl8188eu Refactored rtw_free_assoc_resources MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Refactored rtw_free_assoc_resources to avoid sparse warnings about different contexts for basic lock Signed-off-by: Buţiu Alexandru Octavian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 10 +++++----- drivers/staging/rtl8188eu/core/rtw_mlme.c | 24 ++++++++++++++++-------- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8188eu/include/rtw_mlme.h | 3 ++- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 2 +- 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 8c05cb0..22f5b45 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -183,7 +183,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); @@ -271,7 +271,7 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); @@ -293,7 +293,7 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); @@ -366,7 +366,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, if ((check_fwstate(pmlmepriv, _FW_LINKED)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == true) @@ -415,7 +415,7 @@ u8 rtw_set_802_11_disassociate(struct adapter *padapter) rtw_disassoc_cmd(padapter, 0, true); rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); rtw_pwr_wakeup(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 2b599e3..71a7a85 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -704,7 +704,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (--pmlmepriv->to_roaming == 0 || _SUCCESS != rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)) { pmlmepriv->to_roaming = 0; - rtw_free_assoc_resources(adapter, 1); + rtw_free_assoc_resources(adapter); rtw_indicate_disconnect(adapter); } else { pmlmepriv->to_join = true; @@ -758,7 +758,19 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) /* *rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock */ -void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) +void rtw_free_assoc_resources(struct adapter *adapter) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + rtw_free_assoc_resources_locked(adapter); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); +} + +/* +*rtw_free_assoc_resources_locked: the caller has to lock pmlmepriv->lock +*/ +void rtw_free_assoc_resources_locked(struct adapter *adapter) { struct wlan_network *pwlan = NULL; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -793,8 +805,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) rtw_init_bcmc_stainfo(adapter); } - if (lock_scanned_queue) - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) @@ -805,8 +815,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))) rtw_free_network_nolock(pmlmepriv, pwlan); - if (lock_scanned_queue) - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; } @@ -1302,7 +1310,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) rtw_free_uc_swdec_pending_queue(adapter); - rtw_free_assoc_resources(adapter, 1); + rtw_free_assoc_resources(adapter); rtw_indicate_disconnect(adapter); spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* remove the network entry in scanned_queue */ @@ -1557,7 +1565,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) rtw_disassoc_cmd(adapter, 0, true); rtw_indicate_disconnect(adapter); - rtw_free_assoc_resources(adapter, 0); + rtw_free_assoc_resources_locked(adapter); } rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(supp_ant_div)); diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index a2b54de..9765946 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -70,7 +70,7 @@ static int rtw_hw_suspend(struct adapter *padapter) } } /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); /* s2-4. */ rtw_free_network_queue(padapter, true); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 8c7e8a3..4c99257 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -535,7 +535,8 @@ void rtw_generate_random_ibss(u8 *pibss); struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr); struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); -void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); +void rtw_free_assoc_resources(struct adapter *adapter); +void rtw_free_assoc_resources_locked(struct adapter *adapter); void rtw_indicate_disconnect(struct adapter *adapter); void rtw_indicate_connect(struct adapter *adapter); void rtw_indicate_scan_done(struct adapter *padapter, bool aborted); diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index ce756cd..2db86fb 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1871,7 +1871,7 @@ static int rtw_wx_set_auth(struct net_device *dev, rtw_disassoc_cmd(padapter, 500, false); DBG_88E("%s...call rtw_indicate_disconnect\n ", __func__); rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); } ret = wpa_set_auth_algs(dev, (u32)param->value); break; diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index a14e79f..2361bce 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -1175,7 +1175,7 @@ static int netdev_close(struct net_device *pnetdev) /* s2-2. indicate disconnect to os */ rtw_indicate_disconnect(padapter); /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); /* s2-4. */ rtw_free_network_queue(padapter, true); /* Close LED */ diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 5f44c6a..33bfe05 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -266,7 +266,7 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) /* s2-2. indicate disconnect to os */ rtw_indicate_disconnect(padapter); /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); + rtw_free_assoc_resources(padapter); /* s2-4. */ rtw_free_network_queue(padapter, true); -- 2.7.4