Browse Source

qcacld-3.0: Create wifi kobject if not created by platform driver

Currently host driver creates wifi kobject based on  dump in
progress feature flag, because of this, other features can not
use this wifi kobject.
To address this issue, create wifi kobject if platform driver
does not creates this.

Change-Id: I0ce3616cd229e58de5ab929555be6e1a9eb09c6a
CRs-Fixed: 3262667
Ashish Kumar Dhanotiya 2 years ago
parent
commit
b50ea97a85

+ 5 - 16
core/hdd/inc/wlan_hdd_sysfs_dump_in_progress.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -30,7 +31,7 @@
  *
  * Return: None
  */
-void hdd_sysfs_create_dump_in_progress_interface(void);
+void hdd_sysfs_create_dump_in_progress_interface(struct kobject *wifi_kobject);
 
 /**
  * hdd_sysfs_destroy_dump_in_progress_interface() - API to destroy
@@ -39,27 +40,15 @@ void hdd_sysfs_create_dump_in_progress_interface(void);
  *
  * Return: None
  */
-void hdd_sysfs_destroy_dump_in_progress_interface(void);
-
-void hdd_sysfs_create_wifi_root_obj(void);
-
-void hdd_sysfs_destroy_wifi_root_obj(void);
+void hdd_sysfs_destroy_dump_in_progress_interface(struct kobject *wifi_kobject);
 
 #else
 static inline void
-hdd_sysfs_create_dump_in_progress_interface(void)
+hdd_sysfs_create_dump_in_progress_interface(struct kobject *wifi_kobject)
 {
 }
 static inline void
-hdd_sysfs_destroy_dump_in_progress_interface(void)
-{
-}
-
-static inline void hdd_sysfs_create_wifi_root_obj(void)
-{
-}
-
-static inline void hdd_sysfs_destroy_wifi_root_obj(void)
+hdd_sysfs_destroy_dump_in_progress_interface(struct kobject *wifi_kobject)
 {
 }
 #endif

+ 38 - 3
core/hdd/src/wlan_hdd_sysfs.c

@@ -98,6 +98,7 @@ static struct kobject *wlan_kobject;
 static struct kobject *driver_kobject;
 static struct kobject *fw_kobject;
 static struct kobject *psoc_kobject;
+static struct kobject *wifi_kobject;
 
 int
 hdd_sysfs_validate_and_copy_buf(char *dest_buf, size_t dest_buf_size,
@@ -687,6 +688,40 @@ static void hdd_sysfs_destroy_driver_root_obj(void)
 	}
 }
 
+static void hdd_sysfs_create_wifi_root_obj(struct hdd_context *hdd_ctx)
+{
+	wifi_kobject = pld_get_wifi_kobj(hdd_ctx->parent_dev);
+	if (wifi_kobject) {
+		hdd_debug("wifi_kobject created by platform");
+		return;
+	}
+	wifi_kobject = kobject_create_and_add("wifi", NULL);
+	if (!wifi_kobject)
+		hdd_err("could not allocate wifi kobject");
+}
+
+static void hdd_sysfs_destroy_wifi_root_obj(void)
+{
+	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
+
+	if (!hdd_ctx) {
+		hdd_err("hdd context is NULL");
+		return;
+	}
+	if (pld_get_wifi_kobj(hdd_ctx->parent_dev)) {
+		hdd_debug("wifi_kobject created by platform");
+		wifi_kobject = NULL;
+		return;
+	}
+
+	if (!wifi_kobject) {
+		hdd_err("could not get wifi kobject!");
+		return;
+	}
+	kobject_put(wifi_kobject);
+	wifi_kobject = NULL;
+}
+
 #ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
 static int hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter
 						     *adapter)
@@ -843,10 +878,10 @@ void hdd_create_sysfs_files(struct hdd_context *hdd_ctx)
 	hdd_sysfs_create_driver_root_obj();
 	hdd_sysfs_create_version_interface(hdd_ctx->psoc);
 	hdd_sysfs_mem_stats_create(wlan_kobject);
-	hdd_sysfs_create_wifi_root_obj();
+	hdd_sysfs_create_wifi_root_obj(hdd_ctx);
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
 		hdd_sysfs_create_powerstats_interface();
-		hdd_sysfs_create_dump_in_progress_interface();
+		hdd_sysfs_create_dump_in_progress_interface(wifi_kobject);
 		hdd_sysfs_fw_mode_config_create(driver_kobject);
 		hdd_sysfs_scan_disable_create(driver_kobject);
 		hdd_sysfs_wow_ito_create(driver_kobject);
@@ -885,7 +920,7 @@ void hdd_destroy_sysfs_files(void)
 		hdd_sysfs_wow_ito_destroy(driver_kobject);
 		hdd_sysfs_scan_disable_destroy(driver_kobject);
 		hdd_sysfs_fw_mode_config_destroy(driver_kobject);
-		hdd_sysfs_destroy_dump_in_progress_interface();
+		hdd_sysfs_destroy_dump_in_progress_interface(wifi_kobject);
 		hdd_sysfs_destroy_powerstats_interface();
 	}
 	hdd_sysfs_destroy_wifi_root_obj();

+ 3 - 21
core/hdd/src/wlan_hdd_sysfs_dump_in_progress.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
+* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -29,8 +30,6 @@
 #include "wlan_hdd_sysfs.h"
 #include "osif_sync.h"
 
-static struct kobject *wifi_kobject;
-
 static ssize_t
 __hdd_sysfs_dump_in_progress_store(struct hdd_context *hdd_ctx,
 				   struct kobj_attribute *attr,
@@ -134,7 +133,7 @@ static struct kobj_attribute dump_in_progress_attribute =
 	__ATTR(dump_in_progress, 0660, hdd_sysfs_dump_in_progress_show,
 	       hdd_sysfs_dump_in_progress_store);
 
-void hdd_sysfs_create_dump_in_progress_interface(void)
+void hdd_sysfs_create_dump_in_progress_interface(struct kobject *wifi_kobject)
 {
 	int error;
 
@@ -148,7 +147,7 @@ void hdd_sysfs_create_dump_in_progress_interface(void)
 		hdd_err("could not create dump in progress sysfs file");
 }
 
-void hdd_sysfs_destroy_dump_in_progress_interface(void)
+void hdd_sysfs_destroy_dump_in_progress_interface(struct kobject *wifi_kobject)
 {
 	if (!wifi_kobject) {
 		hdd_err("could not get wifi kobject!");
@@ -159,20 +158,3 @@ void hdd_sysfs_destroy_dump_in_progress_interface(void)
 			  &dump_in_progress_attribute.attr);
 }
 
-void hdd_sysfs_create_wifi_root_obj(void)
-{
-	wifi_kobject = kobject_create_and_add("wifi", NULL);
-	if (!wifi_kobject)
-		hdd_err("could not allocate wifi kobject");
-}
-
-void hdd_sysfs_destroy_wifi_root_obj(void)
-{
-	if (!wifi_kobject) {
-		hdd_err("could not get wifi kobject!");
-		return;
-	}
-	kobject_put(wifi_kobject);
-	wifi_kobject = NULL;
-}
-