staging: rtl8723au: Consolidate duplicate adhoc joining code into rtw_do_join_adhoc()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 9 Jun 2014 13:16:53 +0000 (15:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jun 2014 21:04:23 +0000 (14:04 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_ioctl_set.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/include/rtw_mlme.h

index f3dd9959a9c6841d988c3859bb8eb6d1e56835be..a994893eddeac462deeea3385f441337fea355e9 100644 (file)
@@ -25,7 +25,6 @@
 int rtw_do_join23a(struct rtw_adapter *padapter)
 {
        struct list_head *plist, *phead;
-       u8* pibss = NULL;
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct rtw_queue *queue = &pmlmepriv->scanned_queue;
        int ret = _SUCCESS;
@@ -80,43 +79,10 @@ int rtw_do_join23a(struct rtw_adapter *padapter)
                        pmlmepriv->to_join = false;
                } else {
                        if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                               struct wlan_bssid_ex *pdev_network;
-                               /*  submit createbss_cmd to change to a
-                                   ADHOC_MASTER */
-
-                               /* pmlmepriv->lock has been acquired by
-                                  caller... */
-                               pdev_network =
-                                       &padapter->registrypriv.dev_network;
-
-                               pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
-
-                               pibss = padapter->registrypriv.dev_network.MacAddress;
-
-                               memcpy(&pdev_network->Ssid,
-                                      &pmlmepriv->assoc_ssid,
-                                      sizeof(struct cfg80211_ssid));
-
-                               rtw_update_registrypriv_dev_network23a(padapter);
-
-                               rtw_generate_random_ibss23a(pibss);
-
-                               if (rtw_createbss_cmd23a(padapter) != _SUCCESS) {
-                                       RT_TRACE(_module_rtl871x_ioctl_set_c_,
-                                                _drv_err_,
-                                                ("***Error =>do_goin: rtw_creat"
-                                                 "ebss_cmd status FAIL***\n"));
-                                       ret = _FAIL;
+                               /* switch to ADHOC_MASTER */
+                               ret = rtw_do_join_adhoc(padapter);
+                               if (ret != _SUCCESS)
                                        goto exit;
-                               }
-
-                               pmlmepriv->to_join = false;
-
-                               RT_TRACE(_module_rtl871x_ioctl_set_c_,
-                                        _drv_info_,
-                                        ("***Error => rtw_select_and_join_from"
-                                         "_scanned_queue FAIL under STA_Mode"
-                                         "***\n "));
                        } else {
                                /*  can't associate ; reset under-linking */
                                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
index 77a0a4aa2bbd5efffb4d2f5fe7b5a296155a5b4f..81693c1983cb7089c752fc25a1e0f98af9d15507 100644 (file)
@@ -705,8 +705,6 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
 {
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;
-       struct wlan_bssid_ex *pdev_network;
-       u8 *pibss;
 
        spin_lock_bh(&pmlmepriv->lock);
 
@@ -738,39 +736,8 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
                                set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
 
                                if (rtw_select_and_join_from_scanned_queue23a(
-                                           pmlmepriv) == _SUCCESS) {
-                               } else {
-                                       pdev_network = &adapter->registrypriv.dev_network;
-                                       pibss = adapter->registrypriv.dev_network.MacAddress;
-
-                                       _clr_fwstate_(pmlmepriv,
-                                                     _FW_UNDER_SURVEY);
-
-                                       RT_TRACE(_module_rtl871x_mlme_c_,
-                                                _drv_err_,
-                                                ("switching to adhoc "
-                                                 "master\n"));
-
-                                       memcpy(&pdev_network->Ssid,
-                                              &pmlmepriv->assoc_ssid,
-                                              sizeof(struct cfg80211_ssid));
-
-                                       rtw_update_registrypriv_dev_network23a(
-                                               adapter);
-                                       rtw_generate_random_ibss23a(pibss);
-
-                                       pmlmepriv->fw_state =
-                                               WIFI_ADHOC_MASTER_STATE;
-
-                                       if (rtw_createbss_cmd23a(adapter) !=
-                                           _SUCCESS)
-                                       RT_TRACE(_module_rtl871x_mlme_c_,
-                                                _drv_err_,
-                                                ("Error =>rtw_createbss_cmd23a"
-                                                 " status FAIL\n"));
-
-                                       pmlmepriv->to_join = false;
-                               }
+                                           pmlmepriv) != _SUCCESS)
+                                       rtw_do_join_adhoc(adapter);
                        }
                } else {
                        int ret;
@@ -1425,7 +1392,6 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
        struct sta_info *psta;
        struct wlan_network* pwlan;
        struct wlan_bssid_ex *pdev_network;
-       u8 *pibss;
        struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
        struct stadel_event *pstadel = (struct stadel_event *)pbuf;
        struct sta_priv *pstapriv = &adapter->stapriv;
@@ -1496,30 +1462,11 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
                        spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                        /* re-create ibss */
                        pdev_network = &adapter->registrypriv.dev_network;
-                       pibss = adapter->registrypriv.dev_network.MacAddress;
 
                        memcpy(pdev_network, &tgt_network->network,
                               get_wlan_bssid_ex_sz(&tgt_network->network));
 
-                       memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid,
-                              sizeof(struct cfg80211_ssid));
-
-                       rtw_update_registrypriv_dev_network23a(adapter);
-
-                       rtw_generate_random_ibss23a(pibss);
-
-                       if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
-                               set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE);
-                               _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE);
-                       }
-
-                       if (rtw_createbss_cmd23a(adapter) != _SUCCESS) {
-                               RT_TRACE(_module_rtl871x_ioctl_set_c_,
-                                        _drv_err_,
-                                        ("***Error =>stadel_event_callback: "
-                                         "rtw_createbss_cmd23a status "
-                                         "FAIL***\n"));
-                       }
+                       rtw_do_join_adhoc(adapter);
                }
        }
 
@@ -1777,6 +1724,40 @@ exit:
 }
 
 
+int rtw_do_join_adhoc(struct rtw_adapter *adapter)
+{
+       struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
+       struct wlan_bssid_ex *pdev_network;
+       u8 *ibss;
+       int ret;
+
+       pdev_network = &adapter->registrypriv.dev_network;
+       ibss = adapter->registrypriv.dev_network.MacAddress;
+
+       _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
+
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                ("switching to adhoc master\n"));
+
+       memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid,
+              sizeof(struct cfg80211_ssid));
+
+       rtw_update_registrypriv_dev_network23a(adapter);
+       rtw_generate_random_ibss23a(ibss);
+
+       pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
+
+       ret = rtw_createbss_cmd23a(adapter);
+       if (ret != _SUCCESS) {
+               RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                        ("Error =>rtw_createbss_cmd23a status FAIL\n"));
+       } else  {
+               pmlmepriv->to_join = false;
+       }
+
+       return ret;
+}
+
 int rtw_do_join_network(struct rtw_adapter *adapter,
                        struct wlan_network *candidate)
 {
index e48518f4b1bc1873237d8847f950bfd5a33f213e..79c3b3dec9919ecb8ea00bfb553be556f7206115 100644 (file)
@@ -240,6 +240,7 @@ int rtw_init_mlme_priv23a(struct rtw_adapter *adapter);
 
 void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv);
 
+int rtw_do_join_adhoc(struct rtw_adapter *adapter);
 int rtw_do_join_network(struct rtw_adapter *adapter,
                        struct wlan_network *candidate);
 int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv);