Преглед на файлове

qcacld-3.0: Create feature sysfs node at driver load

Currently host driver creates feature sysfs node at the
timne of start modules.
Based on the new requirement create sysfs node at driver load.

Change-Id: I0030295e69af451eae1c02d6dfae2bcdc2df9cad
CRs-Fixed: 3306174
Ashish Kumar Dhanotiya преди 2 години
родител
ревизия
8e3f52f67b
променени са 5 файла, в които са добавени 68 реда и са изтрити 62 реда
  1. 25 3
      core/hdd/inc/wlan_hdd_sysfs.h
  2. 24 0
      core/hdd/src/wlan_hdd_main.c
  3. 1 13
      core/hdd/src/wlan_hdd_oemdata.c
  4. 11 21
      core/hdd/src/wlan_hdd_sysfs.c
  5. 7 25
      core/hdd/src/wlan_hdd_sysfs_wifi_features.c

+ 25 - 3
core/hdd/inc/wlan_hdd_sysfs.h

@@ -77,13 +77,27 @@ void hdd_destroy_adapter_sysfs_files(struct hdd_adapter *adapter);
  */
 void hdd_create_wifi_feature_interface_sysfs_file(void);
 
+/**
+ * hdd_destroy_wifi_feature_interface_sysfs_file - Destroy wifi feature
+ * interface sysfs file
+ *
+ * Return: none
+ */
+void hdd_destroy_wifi_feature_interface_sysfs_file(void);
+
 /**
  * hdd_sysfs_create_wifi_root_obj() - create wifi root kobj
- * @hdd_ctx: pointer to hdd context
  *
  * Return: none
  */
-void hdd_sysfs_create_wifi_root_obj(struct hdd_context *hdd_ctx);
+void hdd_sysfs_create_wifi_root_obj(void);
+
+/**
+ * hdd_sysfs_destroy_wifi_root_obj() - Destroy wifi root kobj
+ *
+ * Return: none
+ */
+void hdd_sysfs_destroy_wifi_root_obj(void);
 
 #else
 static inline int
@@ -123,7 +137,15 @@ static inline void hdd_create_wifi_feature_interface_sysfs_file(void)
 {
 }
 
-static inline void hdd_sysfs_create_wifi_root_obj(struct hdd_context *hdd_ctx)
+static inline void hdd_destroy_wifi_feature_interface_sysfs_file(void)
+{
+}
+
+static inline void hdd_sysfs_create_wifi_root_obj(void)
+{
+}
+
+static inline void hdd_sysfs_destroy_wifi_root_obj(void)
 {
 }
 #endif /* End of WLAN SYSFS*/

+ 24 - 0
core/hdd/src/wlan_hdd_main.c

@@ -17970,6 +17970,17 @@ static int hdd_register_driver_retry(void)
 	return errno;
 }
 
+/**
+ * hdd_create_wifi_feature_interface() - Create wifi feature interface
+ *
+ * Return: none
+ */
+static void hdd_create_wifi_feature_interface(void)
+{
+	hdd_sysfs_create_wifi_root_obj();
+	hdd_create_wifi_feature_interface_sysfs_file();
+}
+
 int hdd_driver_load(void)
 {
 	struct osif_driver_sync *driver_sync;
@@ -18062,6 +18073,7 @@ int hdd_driver_load(void)
 		hdd_err("Failed to create ctrl param; errno:%d", errno);
 		goto unregister_driver;
 	}
+	hdd_create_wifi_feature_interface();
 out:
 	hdd_debug("%s: driver loaded", WLAN_MODULE_NAME);
 	hdd_place_marker(NULL, "DRIVER LOADED", NULL);
@@ -18107,6 +18119,17 @@ exit:
 EXPORT_SYMBOL(hdd_driver_load);
 #endif
 
+/**
+ * hdd_distroy_wifi_feature_interface() - Distroy wifi feature interface
+ *
+ * Return: none
+ */
+static void hdd_distroy_wifi_feature_interface(void)
+{
+	hdd_destroy_wifi_feature_interface_sysfs_file();
+	hdd_sysfs_destroy_wifi_root_obj();
+}
+
 void hdd_driver_unload(void)
 {
 	struct osif_driver_sync *driver_sync;
@@ -18169,6 +18192,7 @@ void hdd_driver_unload(void)
 	 */
 	osif_driver_sync_trans_stop(driver_sync);
 
+	hdd_distroy_wifi_feature_interface();
 	if (!soft_unload)
 		wlan_hdd_state_ctrl_param_destroy();
 

+ 1 - 13
core/hdd/src/wlan_hdd_oemdata.c

@@ -1173,18 +1173,6 @@ static void hdd_copy_file_name_and_oem_data(
 	}
 }
 
-/**
- * hdd_create_wifi_feature_interface() - Create wifi feature interface
- * @hdd_ctx: pointer to hdd context
- *
- * Return: none
- */
-static void hdd_create_wifi_feature_interface(struct hdd_context *hdd_ctx)
-{
-	hdd_sysfs_create_wifi_root_obj(hdd_ctx);
-	hdd_create_wifi_feature_interface_sysfs_file();
-}
-
 void hdd_oem_event_async_cb(const struct oem_data *oem_event_data)
 {
 	struct sk_buff *vendor_event;
@@ -1201,7 +1189,7 @@ void hdd_oem_event_async_cb(const struct oem_data *oem_event_data)
 
 	if (oem_event_data->file_name) {
 		hdd_copy_file_name_and_oem_data(hdd_ctx, oem_event_data);
-		return hdd_create_wifi_feature_interface(hdd_ctx);
+		return;
 	}
 
 	adapter = hdd_get_adapter_by_vdev(hdd_ctx, oem_event_data->vdev_id);

+ 11 - 21
core/hdd/src/wlan_hdd_sysfs.c

@@ -690,36 +690,25 @@ static void hdd_sysfs_destroy_driver_root_obj(void)
 	}
 }
 
-void hdd_sysfs_create_wifi_root_obj(struct hdd_context *hdd_ctx)
+void hdd_sysfs_create_wifi_root_obj(void)
 {
-	qdf_mutex_acquire(&hdd_ctx->wifi_kobj_lock);
 	if (wifi_kobject) {
 		hdd_debug("wifi kobj already created");
-		goto wifi_kobj_created;
+		return;
 	}
-	wifi_kobject = pld_get_wifi_kobj(hdd_ctx->parent_dev);
+	wifi_kobject = pld_get_wifi_kobj(NULL);
 	if (wifi_kobject) {
 		hdd_debug("wifi_kobject created by platform");
-		goto wifi_kobj_created;
+		return;
 	}
 	wifi_kobject = kobject_create_and_add("wifi", NULL);
 	if (!wifi_kobject)
 		hdd_err("could not allocate wifi kobject");
-
-wifi_kobj_created:
-	qdf_mutex_release(&hdd_ctx->wifi_kobj_lock);
-
 }
 
-static void hdd_sysfs_destroy_wifi_root_obj(void)
+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)) {
+	if (pld_get_wifi_kobj(NULL)) {
 		hdd_debug("wifi_kobject created by platform");
 		wifi_kobject = NULL;
 		return;
@@ -738,6 +727,11 @@ void hdd_create_wifi_feature_interface_sysfs_file(void)
 	hdd_sysfs_create_wifi_feature_interface(wifi_kobject);
 }
 
+void hdd_destroy_wifi_feature_interface_sysfs_file(void)
+{
+	hdd_sysfs_destroy_wifi_feature_interface(wifi_kobject);
+}
+
 #ifdef WLAN_FEATURE_BEACON_RECEPTION_STATS
 static int hdd_sysfs_create_bcn_reception_interface(struct hdd_adapter
 						     *adapter)
@@ -896,9 +890,7 @@ 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_ctx);
 	if  (QDF_GLOBAL_MISSION_MODE == hdd_get_conparam()) {
-		hdd_create_wifi_feature_interface_sysfs_file();
 		hdd_sysfs_create_powerstats_interface();
 		hdd_sysfs_create_dump_in_progress_interface(wifi_kobject);
 		hdd_sysfs_fw_mode_config_create(driver_kobject);
@@ -941,9 +933,7 @@ void hdd_destroy_sysfs_files(void)
 		hdd_sysfs_fw_mode_config_destroy(driver_kobject);
 		hdd_sysfs_destroy_dump_in_progress_interface(wifi_kobject);
 		hdd_sysfs_destroy_powerstats_interface();
-		hdd_sysfs_destroy_wifi_feature_interface(wifi_kobject);
 	}
-	hdd_sysfs_destroy_wifi_root_obj();
 	hdd_sysfs_mem_stats_destroy(wlan_kobject);
 	hdd_sysfs_destroy_version_interface();
 	hdd_sysfs_destroy_driver_root_obj();

+ 7 - 25
core/hdd/src/wlan_hdd_sysfs_wifi_features.c

@@ -35,6 +35,11 @@ static ssize_t  __hdd_sysfs_feature_set_show(struct hdd_context *hdd_ctx,
 	uint8_t i = 0;
 	char const *solution_provider = "QCT";
 
+	if (!hdd_ctx->oem_data) {
+		hdd_debug("Feature info is not available");
+		return 0;
+	}
+
 	for (i = 0; i < hdd_ctx->oem_data_len; i++) {
 		/* The Solution Provider Info is from index 2 to 4 */
 		if (i == 2) {
@@ -77,28 +82,17 @@ static ssize_t hdd_sysfs_feature_set_show(struct kobject *kobj,
 	return errno_size;
 }
 
-static struct kobj_attribute feature_set_attribute;
+static struct kobj_attribute feature_set_attribute =
+	__ATTR(feature, 0660, hdd_sysfs_feature_set_show, NULL);
 
 void hdd_sysfs_create_wifi_feature_interface(struct kobject *wifi_kobject)
 {
-	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
 	int error;
 
-	if (!hdd_ctx)
-		return;
-
-	if (!hdd_ctx->oem_data_len || !hdd_ctx->file_name) {
-		hdd_err("Invalid oem data length or file name");
-		return;
-	}
 	if (!wifi_kobject) {
 		hdd_err("could not get wifi kobject!");
 		return;
 	}
-	feature_set_attribute.attr.name = hdd_ctx->file_name;
-	feature_set_attribute.attr.mode = VERIFY_OCTAL_PERMISSIONS(0660);
-	feature_set_attribute.show = hdd_sysfs_feature_set_show;
-	feature_set_attribute.store = NULL;
 
 	error = sysfs_create_file(wifi_kobject,
 				  &feature_set_attribute.attr);
@@ -108,18 +102,6 @@ void hdd_sysfs_create_wifi_feature_interface(struct kobject *wifi_kobject)
 
 void hdd_sysfs_destroy_wifi_feature_interface(struct kobject *wifi_kobject)
 {
-	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
-
-	if (!hdd_ctx) {
-		hdd_err("HDD context is NULL");
-		return;
-	}
-
-	if (!hdd_ctx->file_name) {
-		hdd_debug("file name is NULL");
-		return;
-	}
-
 	if (!wifi_kobject) {
 		hdd_err("could not get wifi kobject!");
 		return;