ソースを参照

qcacld-3.0: hdd: Refactor wlan_startup (phase 5)

In HDD, hdd_wlan_startup which is called by probe is beast of a
function to maintain. Over time it has grown to such an extent
that it is almost 800 lines of code with in a single function.
Divide the beast into logical smaller functions.

Create separate function for Netlink service init and exit.

Change-Id: I3271784f06ad2a365c4b0ce767a2ba6df67f0b4d
CRs-fixed: 996332
Prashanth Bhatta 9 年 前
コミット
6a6a555220
3 ファイル変更90 行追加50 行削除
  1. 0 1
      Kbuild
  2. 89 47
      core/hdd/src/wlan_hdd_main.c
  3. 1 2
      core/hdd/src/wlan_hdd_power.c

+ 0 - 1
Kbuild

@@ -920,7 +920,6 @@ CDEFINES :=	-DANI_LITTLE_BYTE_ENDIAN \
 		-DWLAN_FEATURE_GTK_OFFLOAD \
 		-DWLAN_WAKEUP_EVENTS \
 		-DFEATURE_WLAN_RA_FILTERING\
-	        -DWLAN_KD_READY_NOTIFIER \
 		-DWLAN_NL80211_TESTMODE \
 		-DFEATURE_WLAN_LPHB \
 		-DFEATURE_WLAN_PAL_TIMER_DISABLE \

+ 89 - 47
core/hdd/src/wlan_hdd_main.c

@@ -3769,6 +3769,82 @@ static inline int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx)
 }
 #endif
 
+/**
+ * hdd_exit_netlink_services - Exit netlink services
+ * @hdd_ctx: HDD context
+ *
+ * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and
+ * nl service.
+ *
+ * Return: None.
+ */
+static void hdd_exit_netlink_services(hdd_context_t *hdd_ctx)
+{
+	cnss_diag_notify_wlan_close();
+
+	hdd_close_cesium_nl_sock();
+
+	ptt_sock_deactivate_svc();
+
+	nl_srv_exit();
+}
+
+/**
+ * hdd_init_netlink_services- Init netlink services
+ * @hdd_ctx: HDD context
+ *
+ * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and
+ * nl service.
+ *
+ * Return: 0 on success and errno on failure.
+ */
+static int hdd_init_netlink_services(hdd_context_t *hdd_ctx)
+{
+	int ret;
+
+	ret = nl_srv_init();
+	if (ret) {
+		hdd_alert("nl_srv_init failed: %d", ret);
+		goto out;
+	}
+
+	ret = oem_activate_service(hdd_ctx);
+	if (ret) {
+		hdd_alert("oem_activate_service failed: %d", ret);
+		goto err_nl_srv;
+	}
+
+	ret = ptt_sock_activate_svc();
+	if (ret) {
+		hdd_alert("ptt_sock_activate_svc failed: %d", ret);
+		goto err_nl_srv;
+	}
+
+	ret = hdd_open_cesium_nl_sock();
+	if (ret) {
+		hdd_alert("hdd_open_cesium_nl_sock failed");
+		goto err_ptt_deactivate;
+	}
+
+	ret = cnss_diag_activate_service();
+	if (ret) {
+		hdd_alert("cnss_diag_activate_service failed: %d", ret);
+		goto err_close_cesium;
+	}
+
+	return 0;
+
+err_close_cesium:
+	hdd_close_cesium_nl_sock();
+err_ptt_deactivate:
+	ptt_sock_deactivate_svc();
+err_nl_srv:
+	nl_srv_exit();
+out:
+	return ret;
+}
+
+
 /**
  * hdd_free_context - Free HDD context
  * @hdd_ctx:	HDD context to be freed.
@@ -3914,16 +3990,10 @@ void hdd_wlan_exit(hdd_context_t *hdd_ctx)
 
 	hdd_wlan_green_ap_deinit(hdd_ctx);
 
-#ifdef WLAN_KD_READY_NOTIFIER
-	cnss_diag_notify_wlan_close();
-	ptt_sock_deactivate_svc();
-#endif /* WLAN_KD_READY_NOTIFIER */
-	nl_srv_exit();
+	hdd_exit_netlink_services(hdd_ctx);
 
 	hdd_close_all_adapters(hdd_ctx, false);
 
-	hdd_close_cesium_nl_sock();
-
 	hdd_ipa_cleanup(hdd_ctx);
 
 	/* Free up RoC request queue and flush workqueue */
@@ -5266,6 +5336,7 @@ hdd_context_t *hdd_init_context(struct device *dev, void *hif_sc)
 
 	hdd_tdls_pre_init(hdd_ctx);
 	mutex_init(&hdd_ctx->dfs_lock);
+	mutex_init(&hdd_ctx->sap_lock);
 
 	init_completion(&hdd_ctx->set_antenna_mode_cmpl);
 
@@ -5785,7 +5856,7 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	ret = hdd_update_country_code(hdd_ctx, adapter);
 
 	if (ret)
-		goto err_cds_disable;
+		goto err_close_adapter;
 
 	sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done);
 
@@ -5795,34 +5866,10 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	/* FW capabilities received, Set the Dot11 mode */
 	sme_setdef_dot11mode(hdd_ctx->hHal);
 
-	/* Initialize the nlink service */
-	if (nl_srv_init() != 0) {
-		hddLog(QDF_TRACE_LEVEL_FATAL, FL("nl_srv_init failed"));
-		goto err_close_adapter;
-	}
-
-	ret = oem_activate_service(hdd_ctx);
-	if (ret) {
-		hdd_alert("oem_activate_service failed: %d", ret);
-		goto err_nl_srv;
-	}
-
-	ret = ptt_sock_activate_svc();
-	if (ret) {
-		hdd_alert("ptt_sock_activate_svc failed: %d", ret);
-		goto err_nl_srv;
-	}
+	ret = hdd_init_netlink_services(hdd_ctx);
 
-	ret = cnss_diag_activate_service();
-	if (ret) {
-		hdd_alert("cnss_diag_activate_service failed: %d", ret);
-		goto err_nl_srv;
-	}
-
-	if (hdd_open_cesium_nl_sock() < 0) {
-		hdd_alert("hdd_open_cesium_nl_sock failed");
-		goto err_nl_srv;
-	}
+	if (ret)
+		goto err_debugfs_exit;
 
 	/*
 	 * Action frame registered in one adapter which will
@@ -5830,15 +5877,13 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	 */
 	wlan_hdd_cfg80211_register_frames(adapter);
 
-	mutex_init(&hdd_ctx->sap_lock);
-
 	hdd_release_rtnl_lock();
 	rtnl_held = false;
 
 	ret = register_netdevice_notifier(&hdd_netdev_notifier);
 	if (ret < 0) {
 		hdd_err("register_netdevice_notifier failed: %d", ret);
-		goto err_nl_srv;
+		goto err_exit_nl_srv;
 	}
 
 #ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
@@ -5878,14 +5923,14 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 	status = cds_init_policy_mgr();
 	if (!QDF_IS_STATUS_SUCCESS(status)) {
 		hdd_err("Policy manager initialization failed");
-		goto err_unreg_netdev_notifier;
+		goto err_exit_nl_srv;
 	}
 
 	ret = hdd_init_thermal_info(hdd_ctx);
 
 	if (ret) {
 		hdd_err("Error while initializing thermal information");
-		goto err_unreg_netdev_notifier;
+		goto err_exit_nl_srv;
 	}
 
 	if (0 != hdd_lro_init(hdd_ctx))
@@ -5969,19 +6014,16 @@ int hdd_wlan_startup(struct device *dev, void *hif_sc)
 err_unreg_netdev_notifier:
 	unregister_netdevice_notifier(&hdd_netdev_notifier);
 
-err_nl_srv:
-#ifdef WLAN_KD_READY_NOTIFIER
-	cnss_diag_notify_wlan_close();
-	ptt_sock_deactivate_svc();
-#endif /* WLAN_KD_READY_NOTIFIER */
-	nl_srv_exit();
+err_exit_nl_srv:
+	hdd_exit_netlink_services(hdd_ctx);
 
 	if (!QDF_IS_STATUS_SUCCESS(cds_deinit_policy_mgr())) {
 		hdd_err("Failed to deinit policy manager");
 		/* Proceed and complete the clean up */
 	}
 
-	hdd_close_cesium_nl_sock();
+err_debugfs_exit:
+	hdd_debugfs_exit(adapter);
 
 err_close_adapter:
 	hdd_release_rtnl_lock();

+ 1 - 2
core/hdd/src/wlan_hdd_power.c

@@ -1622,10 +1622,9 @@ err_cds_close:
 	if (pHddCtx) {
 		/* Unregister the Net Device Notifier */
 		unregister_netdevice_notifier(&hdd_netdev_notifier);
-#ifdef WLAN_KD_READY_NOTIFIER
 		cnss_diag_notify_wlan_close();
 		ptt_sock_deactivate_svc();
-#endif /* WLAN_KD_READY_NOTIFIER */
+
 		nl_srv_exit();
 
 		/* Free up dynamically allocated members inside HDD Adapter */