diff --git a/core/hdd/inc/wlan_hdd_regulatory.h b/core/hdd/inc/wlan_hdd_regulatory.h index e9af6aba28f1..3c00bd90dea1 100644 --- a/core/hdd/inc/wlan_hdd_regulatory.h +++ b/core/hdd/inc/wlan_hdd_regulatory.h @@ -41,6 +41,22 @@ struct hdd_context; */ int hdd_update_regulatory_config(struct hdd_context *hdd_ctx); +/** + * hdd_init_regulatory_update_event() - Initialize the regulatory update event + * @hdd_ctx: HDD context + * + * Return: 0 on success, err on failure + */ +int hdd_init_regulatory_update_event(struct hdd_context *hdd_ctx); + +/** + * hdd_deinit_regulatory_update_event() - Cleanup the regulatory update event + * @hdd_ctx: HDD context + * + * Return: none + */ +void hdd_deinit_regulatory_update_event(struct hdd_context *hdd_ctx); + int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy); /** diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 5027fa945b6b..1cc3f6ee5b15 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -9371,6 +9371,8 @@ void hdd_wlan_exit(struct hdd_context *hdd_ctx) hdd_wlan_stop_modules(hdd_ctx, false); + hdd_deinit_regulatory_update_event(hdd_ctx); + hdd_driver_memdump_deinit(); qdf_nbuf_deinit_replenish_timer(); @@ -15051,6 +15053,13 @@ int hdd_wlan_startup(struct hdd_context *hdd_ctx) hdd_dp_trace_init(hdd_ctx->config); + errno = hdd_init_regulatory_update_event(hdd_ctx); + if (errno) { + hdd_err("Failed to initialize regulatory update event; errno:%d", + errno); + goto memdump_deinit; + } + errno = hdd_wlan_start_modules(hdd_ctx, false); if (errno) { hdd_err("Failed to start modules; errno:%d", errno); diff --git a/core/hdd/src/wlan_hdd_regulatory.c b/core/hdd/src/wlan_hdd_regulatory.c index a206ea280af7..bf16251d309c 100644 --- a/core/hdd/src/wlan_hdd_regulatory.c +++ b/core/hdd/src/wlan_hdd_regulatory.c @@ -1678,6 +1678,26 @@ int hdd_update_regulatory_config(struct hdd_context *hdd_ctx) return 0; } +int hdd_init_regulatory_update_event(struct hdd_context *hdd_ctx) +{ + QDF_STATUS status; + + status = qdf_event_create(&hdd_ctx->regulatory_update_event); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to create regulatory update event"); + goto failure; + } + status = qdf_mutex_create(&hdd_ctx->regulatory_status_lock); + if (QDF_IS_STATUS_ERROR(status)) { + hdd_err("Failed to create regulatory status mutex"); + goto failure; + } + hdd_ctx->is_regulatory_update_in_progress = false; + +failure: + return qdf_status_to_os_return(status); +} + int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy) { bool offload_enabled; @@ -1696,10 +1716,6 @@ int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy) hdd_regulatory_dyn_cbk, NULL); - qdf_event_create(&hdd_ctx->regulatory_update_event); - qdf_mutex_create(&hdd_ctx->regulatory_status_lock); - hdd_ctx->is_regulatory_update_in_progress = false; - wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED; /* Check the kernel version for upstream commit aced43ce780dc5 that * has support for processing user cell_base hints when wiphy is @@ -1758,12 +1774,22 @@ int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy) } #endif +void hdd_deinit_regulatory_update_event(struct hdd_context *hdd_ctx) +{ + QDF_STATUS status; + + status = qdf_event_destroy(&hdd_ctx->regulatory_update_event); + if (QDF_IS_STATUS_ERROR(status)) + hdd_err("Failed to destroy regulatory update event"); + status = qdf_mutex_destroy(&hdd_ctx->regulatory_status_lock); + if (QDF_IS_STATUS_ERROR(status)) + hdd_err("Failed to destroy regulatory status mutex"); +} + void hdd_regulatory_deinit(struct hdd_context *hdd_ctx) { qdf_flush_work(&hdd_ctx->country_change_work); qdf_destroy_work(0, &hdd_ctx->country_change_work); - qdf_event_destroy(&hdd_ctx->regulatory_update_event); - qdf_mutex_destroy(&hdd_ctx->regulatory_status_lock); } void hdd_update_regdb_offload_config(struct hdd_context *hdd_ctx)