Browse Source

qcacld-3.0: wma: Remove logs for wma_handle checks

wma_validate_handle() function already takes care of logging the
caller function name in case of any error.
Hence there is no need to add the error log again.
Getting rid of these unnecessary logs reduces driver memory footprint.

Change-Id: I65f87eee08ad87579ea3cdeab0a6db2c2db02fb7
CRs-Fixed: 2833851
Srinivas Girigowda 4 years ago
parent
commit
50a57ae9f7

+ 2 - 0
core/wma/inc/wma.h

@@ -1044,6 +1044,8 @@ typedef struct {
  * wma_validate_handle() - Validate WMA handle
  * @wma_handle: wma handle
  *
+ * This function will log on error and hence caller should not log on error
+ *
  * Return: errno if WMA handle is NULL; 0 otherwise
  */
 #define wma_validate_handle(wma_handle) \

+ 1 - 3
core/wma/src/wma_coex.c

@@ -341,10 +341,8 @@ void wma_get_mws_coex_info_req(tp_wma_handle wma_handle,
 
 void wma_register_mws_coex_events(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 				wmi_vdev_get_mws_coex_state_eventid,

+ 4 - 8
core/wma/src/wma_data.c

@@ -955,10 +955,8 @@ wma_data_tx_ack_comp_hdlr(void *wma_context, qdf_nbuf_t netbuf, int32_t status)
 {
 	tp_wma_handle wma_handle = (tp_wma_handle) wma_context;
 
-	if (!wma_handle) {
-		wma_err("Invalid WMA Handle");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	/*
 	 * if netBuf does not match with pending nbuf then just free the
@@ -1991,10 +1989,8 @@ int wma_thermal_mgmt_evt_handler(void *handle, uint8_t *event, uint32_t len)
 
 	wma = (tp_wma_handle) handle;
 
-	if (!wma) {
-		wma_err("Failed to get wma handle");
+	if (wma_validate_handle(wma))
 		return -EINVAL;
-	}
 
 	param_buf = (WMI_THERMAL_MGMT_EVENTID_param_tlvs *) event;
 
@@ -2250,11 +2246,11 @@ QDF_STATUS wma_tx_packet(void *wma_context, void *tx_frame, uint16_t frmLen,
 	bool is_5g = false;
 	uint8_t pdev_id;
 
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (wma_validate_handle(wma_handle)) {
 		cds_packet_free((void *)tx_frame);
 		return QDF_STATUS_E_FAILURE;
 	}
+
 	iface = &wma_handle->interfaces[vdev_id];
 
 	if (!soc) {

+ 3 - 9
core/wma/src/wma_features.c

@@ -512,10 +512,8 @@ QDF_STATUS wma_process_dhcp_ind(WMA_HANDLE handle,
 	uint8_t vdev_id;
 	wmi_peer_set_param_cmd_fixed_param peer_set_param_fp = {0};
 
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	if (!ta_dhcp_ind) {
 		wma_err("DHCP indication is NULL");
@@ -3995,10 +3993,8 @@ QDF_STATUS wma_set_tx_rx_aggr_size_per_ac(WMA_HANDLE handle,
 	uint32_t tx_aggr_size[4];
 	tp_wma_handle wma_handle = (tp_wma_handle)handle;
 
-	if (!wma_handle) {
-		wma_err("WMA context is invald!");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	tx_aggr_size[0] = qos_aggr->tx_aggregation_size_be;
 	tx_aggr_size[1] = qos_aggr->tx_aggregation_size_bk;
@@ -4105,10 +4101,8 @@ QDF_STATUS wma_set_sw_retry_threshold_per_ac(WMA_HANDLE handle,
 	uint32_t sw_retry;
 	tp_wma_handle wma_handle = (tp_wma_handle)handle;
 
-	if (!wma_handle) {
-		wma_err("WMA context is invalid!");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	tx_sw_retry[WMI_VDEV_CUSTOM_SW_RETRY_TYPE_AGGR][WMI_AC_BE] =
 		qos_aggr->tx_aggr_sw_retry_threshold_be;

+ 1 - 3
core/wma/src/wma_he.c

@@ -1395,10 +1395,8 @@ QDF_STATUS wma_update_he_ops_ie(tp_wma_handle wma, uint8_t vdev_id,
 	QDF_STATUS ret;
 	uint32_t dword_he_op = 0;
 
-	if (!wma) {
-		wma_err("wrong wma_handle....");
+	if (wma_validate_handle(wma))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	WMI_HEOPS_COLOR_SET(dword_he_op, he_op->bss_color);
 	WMI_HEOPS_DEFPE_SET(dword_he_op, he_op->default_pe);

+ 39 - 130
core/wma/src/wma_main.c

@@ -169,10 +169,8 @@ static void wma_service_ready_ext_evt_timeout(void *data)
  */
 struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
 {
-	if (!wma) {
-		wma_err("Invalid WMA context");
+	if (wma_validate_handle(wma))
 		return NULL;
-	}
 
 	return &wma->ini_config;
 }
@@ -378,11 +376,8 @@ int wma_cli_get_command(int vdev_id, int param_id, int vpdev)
 	struct wma_txrx_node *intr = NULL;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-
-	if (!wma) {
-		wma_err("Invalid wma handle");
+	if (!wma)
 		return -EINVAL;
-	}
 
 	intr = wma->interfaces;
 
@@ -1506,10 +1501,8 @@ wma_vdev_nss_chain_params_send(uint8_t vdev_id,
 {
 	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 	struct vdev_nss_chains vdev_user_cfg;
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (!wma_handle)
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	vdev_user_cfg.disable_rx_mrc[NSS_CHAINS_BAND_2GHZ] =
 				user_cfg->disable_rx_mrc[NSS_CHAINS_BAND_2GHZ];
@@ -1772,10 +1765,8 @@ static void wma_state_info_dump(char **buf_ptr, uint16_t *size)
 	QDF_STATUS status;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("WMA context is invalid!");
+	if (!wma)
 		return;
-	}
 
 	wma_debug("size of buffer: %d", *size);
 
@@ -2315,10 +2306,8 @@ static QDF_STATUS spectral_phyerr_event_handler(void *handle,
 	struct target_if_spectral_chan_info chan_info;
 	struct target_if_spectral_acs_stats acs_stats;
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (wma_validate_handle(wma))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	memset(&phyerr, 0, sizeof(wmi_host_phyerr_t));
 	status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
@@ -2478,10 +2467,8 @@ static int wma_unified_phyerr_rx_event_handler(void *handle,
 	wmi_host_phyerr_t phyerr2;
 	bool spectralscan = false;
 
-	if (!wma) {
-		wma_err("wma handle is null");
+	if (wma_validate_handle(wma))
 		return -EINVAL;
-	}
 
 	/* sanity check on data length */
 	status = wmi_extract_comb_phyerr(wma->wmi_handle, data, datalen,
@@ -2553,11 +2540,8 @@ void wma_vdev_deinit(struct wma_txrx_node *vdev)
 	tp_wma_handle wma_handle;
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	/* validate the wma_handle */
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return;
-	}
 
 	bcn = vdev->beacon;
 	if (bcn) {
@@ -2660,11 +2644,8 @@ static QDF_STATUS wma_register_swba_events(wmi_unified_t wmi_handle)
 #ifdef FEATURE_WLAN_APF
 static void wma_register_apf_events(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
-			  "wma_handle is NULL\n");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 					   wmi_apf_capability_info_event_id,
@@ -2689,11 +2670,8 @@ static void wma_register_apf_events(tp_wma_handle wma_handle)
  */
 static void wma_register_md_events(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
-			  "wma_handle is NULL\n");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 					   wmi_motion_det_host_eventid,
@@ -3490,7 +3468,6 @@ QDF_STATUS wma_pre_start(void)
 
 	/* Validate the wma_handle */
 	if (!wma_handle) {
-		wma_err("invalid wma handle");
 		qdf_status = QDF_STATUS_E_INVAL;
 		goto end;
 	}
@@ -3637,8 +3614,7 @@ static int wma_pdev_set_hw_mode_resp_evt_handler(void *handle,
 	struct sir_set_hw_mode_resp *hw_mode_resp;
 	tp_wma_handle wma = (tp_wma_handle) handle;
 
-	if (!wma) {
-		wma_err("Invalid WMA handle");
+	if (wma_validate_handle(wma)) {
 		/* Since WMA handle itself is NULL, we cannot send fail
 		 * response back to LIM here
 		 */
@@ -3845,9 +3821,8 @@ static int wma_pdev_hw_mode_transition_evt_handler(void *handle,
 	struct sir_hw_mode_trans_ind *hw_mode_trans_ind;
 	tp_wma_handle wma = (tp_wma_handle) handle;
 
-	if (!wma) {
+	if (wma_validate_handle(wma)) {
 		/* This is an async event. So, not sending any event to LIM */
-		wma_err("Invalid WMA handle");
 		return QDF_STATUS_E_NULL_VALUE;
 	}
 
@@ -3911,8 +3886,7 @@ static int wma_pdev_set_dual_mode_config_resp_evt_handler(void *handle,
 	tp_wma_handle wma = (tp_wma_handle) handle;
 	struct sir_dual_mac_config_resp *dual_mac_cfg_resp;
 
-	if (!wma) {
-		wma_err("Invalid WMA handle");
+	if (wma_validate_handle(wma)) {
 		/* Since the WMA handle is NULL, we cannot send resp to LIM.
 		 * So, returning from here.
 		 */
@@ -4015,9 +3989,7 @@ QDF_STATUS wma_start(void)
 	wma_debug("Enter");
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	/* validate the wma_handle */
 	if (!wma_handle) {
-		wma_err("Invalid wma handle");
 		qdf_status = QDF_STATUS_E_INVAL;
 		goto end;
 	}
@@ -4263,15 +4235,12 @@ QDF_STATUS wma_stop(void)
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 	wma_debug("Enter");
-	/* validate the wma_handle */
 	if (!wma_handle) {
-		wma_err("Invalid handle");
 		qdf_status = QDF_STATUS_E_INVAL;
 		goto end;
 	}
 	mac = cds_get_context(QDF_MODULE_ID_PE);
 	if (!mac) {
-		wma_err("Invalid mac context");
 		goto end;
 	}
 #ifdef QCA_WIFI_FTM
@@ -4346,12 +4315,8 @@ QDF_STATUS wma_wmi_service_close(void)
 	}
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-
-	/* validate the wma_handle */
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	/* validate the wmi handle */
 	if (!wma_handle->wmi_handle) {
@@ -4395,12 +4360,8 @@ QDF_STATUS wma_wmi_work_close(void)
 	wma_debug("Enter");
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-
-	/* validate the wma_handle */
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	/* validate the wmi handle */
 	if (!wma_handle->wmi_handle) {
@@ -4431,12 +4392,8 @@ QDF_STATUS wma_close(void)
 	wma_debug("Enter");
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-
-	/* validate the wma_handle */
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	/* validate the wmi handle */
 	if (!wma_handle->wmi_handle) {
@@ -5573,10 +5530,8 @@ static void wma_dump_dbs_hw_mode(tp_wma_handle wma_handle)
 {
 	uint32_t i, param;
 
-	if (!wma_handle) {
-		wma_err("Invalid WMA handle");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	for (i = 0; i < wma_handle->num_dbs_hw_modes; i++) {
 		param = wma_handle->hw_mode.hw_mode_list[i];
@@ -5631,10 +5586,8 @@ static void wma_set_pmo_caps(struct wlan_objmgr_psoc *psoc)
 	struct pmo_device_caps caps;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma handler is null");
+	if (!wma)
 		return;
-	}
 
 	caps.arp_ns_offload =
 		wmi_service_enabled(wma->wmi_handle, wmi_service_arpns_offload);
@@ -5671,10 +5624,8 @@ static void wma_set_mlme_caps(struct wlan_objmgr_psoc *psoc)
 	QDF_STATUS status;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma handler is null");
+	if (!wma)
 		return;
-	}
 
 	tgt_cap = wmi_service_enabled(wma->wmi_handle,
 				      wmi_service_adaptive_11r_support);
@@ -5729,10 +5680,8 @@ static QDF_STATUS wma_register_gtk_offload_event(tp_wma_handle wma_handle)
 {
 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
 
-	if (!wma_handle) {
-		wma_err("wma_handle passed is NULL");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	if (wmi_service_enabled(wma_handle->wmi_handle,
 				wmi_service_gtk_offload)) {
@@ -6084,10 +6033,8 @@ QDF_STATUS wma_get_caps_for_phyidx_hwmode(struct wma_caps_per_phy *caps_per_phy,
 	struct wlan_psoc_target_capability_info *tgt_cap_info;
 	uint8_t total_mac_phy_cnt, i;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
 	if (!tgt_hdl) {
@@ -6211,10 +6158,8 @@ bool wma_is_rx_ldpc_supported_for_channel(uint32_t ch_freq)
 	bool status;
 	uint8_t num_hw_modes;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return false;
-	}
 
 	tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
 	if (!tgt_hdl) {
@@ -6495,10 +6440,8 @@ static QDF_STATUS wma_update_hw_mode_list(t_wma_handle *wma_handle,
 	struct wlan_psoc_target_capability_info *tgt_cap_info;
 	int num_hw_modes;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	num_hw_modes = target_psoc_get_num_hw_modes(tgt_hdl);
 	mac_phy_cap = target_psoc_get_mac_phy_cap(tgt_hdl);
@@ -6712,10 +6655,8 @@ int wma_rx_service_ready_ext_event(void *handle, uint8_t *event,
 
 	wma_debug("Enter");
 
-	if (!wma_handle) {
-		wma_err("Invalid WMA handle");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
 	wmi_handle = get_wmi_unified_hdl_from_psoc(wma_handle->psoc);
 
@@ -6937,7 +6878,6 @@ void wma_setneedshutdown(void)
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
 	if (!wma_handle) {
-		wma_err("Invalid arguments");
 		QDF_ASSERT(0);
 		return;
 	}
@@ -6960,7 +6900,6 @@ bool wma_needshutdown(void)
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
 	if (!wma_handle) {
-		wma_err("Invalid arguments");
 		QDF_ASSERT(0);
 		return false;
 	}
@@ -7021,10 +6960,8 @@ QDF_STATUS wma_set_ppsconfig(uint8_t vdev_id, uint16_t pps_param,
 	int ret = -EIO;
 	uint32_t pps_val;
 
-	if (!wma) {
-		wma_err("Failed to get wma");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	switch (pps_param) {
 	case WMA_VHT_PPS_PAID_MATCH:
@@ -7225,10 +7162,8 @@ static void wma_enable_specific_fw_logs(tp_wma_handle wma_handle,
 		wma_err("start_log pointer is NULL");
 		return;
 	}
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	if (!((start_log->ring_id == RING_ID_CONNECTIVITY) ||
 			(start_log->ring_id == RING_ID_FIRMWARE_DEBUG))) {
@@ -7270,10 +7205,8 @@ static void wma_set_wifi_start_packet_stats(void *wma_handle,
 		wma_err("start_log pointer is NULL");
 		return;
 	}
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	/* No need to register for ring IDs other than packet stats */
 	if (start_log->ring_id != RING_ID_PER_PACKET_STATS) {
@@ -7597,10 +7530,8 @@ static QDF_STATUS wma_process_power_debug_stats_req(tp_wma_handle wma_handle)
 	uint8_t *buf_ptr;
 	int ret;
 
-	if (!wma_handle) {
-		wma_err("input pointer is NULL");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	len = sizeof(*cmd);
 	buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
@@ -7643,10 +7574,8 @@ static QDF_STATUS wma_process_beacon_debug_stats_req(tp_wma_handle wma_handle,
 	int ret;
 
 	wma_debug("Enter");
-	if (!wma_handle) {
-		wma_err("input pointer is NULL");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	len = sizeof(*cmd);
 	buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
@@ -7825,10 +7754,9 @@ QDF_STATUS wma_set_rx_reorder_timeout_val(tp_wma_handle wma_handle,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	if (!wma_handle) {
-		wma_err("WMA context is invalid!");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
+
 	len = sizeof(*cmd);
 	buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
 	if (!buf)
@@ -7872,10 +7800,8 @@ QDF_STATUS wma_set_rx_blocksize(tp_wma_handle wma_handle,
 		return QDF_STATUS_E_INVAL;
 	}
 
-	if (!wma_handle) {
-		wma_err("WMA context is invalid!");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	len = sizeof(*cmd);
 	buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
@@ -7915,10 +7841,8 @@ QDF_STATUS wma_get_chain_rssi(tp_wma_handle wma_handle,
 	uint32_t len = sizeof(wmi_pdev_div_get_rssi_antid_fixed_param);
 	u_int8_t *buf_ptr;
 
-	if (!wma_handle) {
-		wma_err("WMA is closed, can not issue cmd");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len);
 	if (!wmi_buf)
@@ -8421,9 +8345,7 @@ static QDF_STATUS wma_mc_process_msg(struct scheduler_msg *msg)
 		 mac_trace_get_wma_msg_string(msg->type));
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-
 	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
 		QDF_ASSERT(0);
 		qdf_mem_free(msg->bodyptr);
 		qdf_status = QDF_STATUS_E_INVAL;
@@ -9137,10 +9059,8 @@ QDF_STATUS wma_send_set_pcl_cmd(tp_wma_handle wma_handle,
 	uint32_t i;
 	QDF_STATUS status;
 
-	if (!wma_handle) {
-		wma_err("WMA handle is NULL. Cannot issue command");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_NULL_VALUE;
-	}
 
 	/*
 	 * if vdev_id is WLAN_UMAC_VDEV_ID_MAX, then roaming is enabled on
@@ -9216,8 +9136,7 @@ QDF_STATUS wma_send_pdev_set_hw_mode_cmd(tp_wma_handle wma_handle,
 	struct sir_set_hw_mode_resp *param;
 	struct wma_target_req *timeout_msg;
 
-	if (!wma_handle) {
-		wma_err("WMA handle is NULL. Cannot issue command");
+	if (wma_validate_handle(wma_handle)) {
 		/* Handle is NULL. Will not be able to send failure
 		 * response as well
 		 */
@@ -9277,10 +9196,8 @@ QDF_STATUS wma_send_pdev_set_dual_mac_config(tp_wma_handle wma_handle,
 	struct wma_target_req *req_msg;
 	struct sir_dual_mac_config_resp *resp;
 
-	if (!wma_handle) {
-		wma_err("WMA handle is NULL. Cannot issue command");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_NULL_VALUE;
-	}
 
 	if (!msg) {
 		wma_err("Set dual mode config is NULL");
@@ -9347,10 +9264,8 @@ QDF_STATUS wma_send_pdev_set_antenna_mode(tp_wma_handle wma_handle,
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 	struct sir_antenna_mode_resp *param;
 
-	if (!wma_handle) {
-		wma_err("WMA handle is NULL. Cannot issue command");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_NULL_VALUE;
-	}
 
 	if (!msg) {
 		wma_err("Set antenna mode param is NULL");
@@ -9461,10 +9376,8 @@ QDF_STATUS wma_configure_smps_params(uint32_t vdev_id, uint32_t param_id,
 	int smps_cmd_value;
 	int status = QDF_STATUS_E_INVAL;
 
-	if (!wma) {
-		wma_err("Failed to get wma");
+	if (!wma)
 		return status;
-	}
 
 	smps_cmd_value = param_id << WMI_SMPS_PARAM_VALUE_S;
 	smps_cmd_value = smps_cmd_value | param_val;
@@ -9491,10 +9404,8 @@ QDF_STATUS wma_config_bmiss_bcnt_params(uint32_t vdev_id, uint32_t first_cnt,
 	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 	int status = QDF_STATUS_E_INVAL;
 
-	if (!wma_handle) {
-		wma_err("Failed to get wma");
+	if (!wma_handle)
 		return status;
-	}
 
 	status = wma_roam_scan_bmiss_cnt(wma_handle, first_cnt, final_cnt,
 			vdev_id);
@@ -9514,10 +9425,8 @@ QDF_STATUS wma_get_rx_chainmask(uint8_t pdev_id, uint32_t *chainmask_2g,
 	uint32_t hw_mode_idx = 0, num_hw_modes = 0;
 
 	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (!wma_handle)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	tgt_hdl = wlan_psoc_get_tgt_if_handle(wma_handle->psoc);
 	if (!tgt_hdl) {

+ 14 - 40
core/wma/src/wma_mgmt.c

@@ -799,10 +799,8 @@ void wma_set_sta_keep_alive(tp_wma_handle wma, uint8_t vdev_id,
 {
 	struct sta_keep_alive_params params = { 0 };
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (wma_validate_handle(wma))
 		return;
-	}
 
 	if (timeperiod > cfg_max(CFG_INFRA_STA_KEEP_ALIVE_PERIOD)) {
 		wmi_err("Invalid period %d Max limit %d", timeperiod,
@@ -2158,10 +2156,8 @@ int wma_tbttoffset_update_event_handler(void *handle, uint8_t *event,
 	uint32_t *adjusted_tsf = NULL;
 	uint32_t if_id = 0, vdev_map;
 
-	if (!wma) {
-		wma_err("Invalid wma handle");
+	if (wma_validate_handle(wma))
 		return -EINVAL;
-	}
 
 	param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) event;
 	if (!param_buf) {
@@ -2223,10 +2219,8 @@ int wma_tbttoffset_update_event_handler(void *handle, uint8_t *event,
 static int wma_p2p_go_set_beacon_ie(t_wma_handle *wma_handle,
 				    A_UINT32 vdev_id, uint8_t *p2pIe)
 {
-	if (!wma_handle) {
-		wma_err("wma handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	return wmi_unified_p2p_go_set_beacon_ie_cmd(wma_handle->wmi_handle,
 							vdev_id, p2pIe);
@@ -2419,10 +2413,8 @@ void wlan_cm_send_beacon_miss(uint8_t vdev_id, int32_t rssi)
 	tp_wma_handle wma;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("Invalid wma");
+	if (!wma)
 		return;
-	}
 
 	wma_beacon_miss_handler(wma, vdev_id, rssi);
 }
@@ -2510,10 +2502,8 @@ static int wma_process_mgmt_tx_completion(tp_wma_handle wma_handle,
 #endif
 	struct wmi_mgmt_params mgmt_params = {};
 
-	if (!wma_handle) {
-		wma_err("wma handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
 	wma_debug("status: %s wmi_desc_id: %d",
 		  wma_get_status_str(status), desc_id);
@@ -2860,10 +2850,8 @@ QDF_STATUS wma_set_htconfig(uint8_t vdev_id, uint16_t ht_capab, int value)
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 	QDF_STATUS ret = QDF_STATUS_E_FAILURE;
 
-	if (!wma) {
-		wma_err("Failed to get wma");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	switch (ht_capab) {
 	case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
@@ -3332,7 +3320,6 @@ int wma_form_rx_packet(qdf_nbuf_t buf,
 	static uint8_t limit_prints_recovery = RATE_LIMIT - 1;
 
 	if (!wma_handle) {
-		wma_err("wma handle is NULL");
 		qdf_nbuf_free(buf);
 		qdf_mem_free(rx_pkt);
 		return -EINVAL;
@@ -3573,10 +3560,8 @@ static int wma_mgmt_rx_process(void *handle, uint8_t *data,
 	qdf_nbuf_t wbuf;
 	QDF_STATUS status;
 
-	if (!wma_handle) {
-		wma_err("Failed to get WMA  context");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
 	mgmt_rx_params = qdf_mem_malloc(sizeof(*mgmt_rx_params));
 	if (!mgmt_rx_params) {
@@ -3685,10 +3670,8 @@ QDF_STATUS wma_de_register_mgmt_frm_client(void)
 	tp_wma_handle wma_handle = (tp_wma_handle)
 				cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("Failed to get WMA context");
+	if (!wma_handle)
 		return QDF_STATUS_E_NULL_VALUE;
-	}
 
 #ifdef QCA_WIFI_FTM
 	if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE)
@@ -3732,10 +3715,9 @@ QDF_STATUS wma_register_roaming_callbacks(
 
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma) {
-		wma_err("Failed to get WMA context");
+	if (!wma)
 		return QDF_STATUS_E_FAILURE;
-	}
+
 	wma->csr_roam_synch_cb = csr_roam_synch_cb;
 	wma->csr_roam_auth_event_handle_cb = csr_roam_auth_event_handle_cb;
 	wma->pe_roam_synch_cb = pe_roam_synch_cb;
@@ -3759,10 +3741,8 @@ QDF_STATUS wma_register_mgmt_frm_client(void)
 	tp_wma_handle wma_handle = (tp_wma_handle)
 				cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("Failed to get WMA context");
+	if (!wma_handle)
 		return QDF_STATUS_E_NULL_VALUE;
-	}
 
 	if (wmi_unified_register_event_handler(wma_handle->wmi_handle,
 					       wmi_mgmt_rx_event_id,
@@ -3792,10 +3772,8 @@ void wma_register_packetdump_callback(
 {
 	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("wma handle is NULL");
+	if (!wma_handle)
 		return;
-	}
 
 	wma_handle->wma_mgmt_tx_packetdump_cb = tx_cb;
 	wma_handle->wma_mgmt_rx_packetdump_cb = rx_cb;
@@ -3814,10 +3792,8 @@ void wma_deregister_packetdump_callback(void)
 {
 	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("wma handle is NULL");
+	if (!wma_handle)
 		return;
-	}
 
 	wma_handle->wma_mgmt_tx_packetdump_cb = NULL;
 	wma_handle->wma_mgmt_rx_packetdump_cb = NULL;
@@ -3846,10 +3822,8 @@ QDF_STATUS wma_mgmt_unified_cmd_send(struct wlan_objmgr_vdev *vdev,
 	}
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma_handle) {
-		wma_err("wma handle is NULL");
+	if (!wma_handle)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	if (wmi_service_enabled(wma_handle->wmi_handle,
 				   wmi_service_mgmt_tx_wmi)) {

+ 9 - 22
core/wma/src/wma_power.c

@@ -106,10 +106,9 @@ QDF_STATUS wma_unified_set_sta_ps_param(wmi_unified_t wmi_handle,
 	QDF_STATUS status;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma is NULL");
+	if (!wma)
 		return QDF_STATUS_E_FAILURE;
-	}
+
 	wma_debug("Set Sta Ps param vdevId %d Param %d val %d",
 		 vdev_id, param, value);
 	iface = &wma->interfaces[vdev_id];
@@ -615,10 +614,8 @@ void wma_enable_sta_ps_mode(tpEnablePsParams ps_req)
 	t_wma_handle *wma_handle;
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma_handle) {
-		wma_err("wma handle is null");
+	if (!wma_handle)
 		return;
-	}
 
 	iface = &wma_handle->interfaces[vdev_id];
 
@@ -722,10 +719,8 @@ void wma_disable_sta_ps_mode(tpDisablePsParams ps_req)
 	t_wma_handle *wma_handle;
 
 	wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma_handle) {
-		wma_err("wma handle is null");
+	if (!wma_handle)
 		return;
-	}
 
 	iface = &wma_handle->interfaces[vdev_id];
 
@@ -759,10 +754,8 @@ QDF_STATUS wma_set_power_config(uint8_t vdev_id, enum powersave_mode power)
 {
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma) {
-		wma_err("WMA context is invalid!");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wma_info("configuring power: %d", power);
 	wma->powersave_mode = power;
@@ -1503,13 +1496,10 @@ QDF_STATUS wma_set_smps_params(tp_wma_handle wma, uint8_t vdev_id,
 QDF_STATUS wma_set_tx_power_scale(uint8_t vdev_id, int value)
 {
 	QDF_STATUS ret;
-	tp_wma_handle wma_handle =
-			(tp_wma_handle)cds_get_context(QDF_MODULE_ID_WMA);
+	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (!wma_handle)
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	if (!wma_is_vdev_up(vdev_id)) {
 		wma_err("vdev id %d is not up", vdev_id);
@@ -1534,13 +1524,10 @@ QDF_STATUS wma_set_tx_power_scale(uint8_t vdev_id, int value)
 QDF_STATUS wma_set_tx_power_scale_decr_db(uint8_t vdev_id, int value)
 {
 	QDF_STATUS ret;
-	tp_wma_handle wma_handle =
-			(tp_wma_handle)cds_get_context(QDF_MODULE_ID_WMA);
+	tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (!wma_handle)
 		return QDF_STATUS_E_FAILURE;
-	}
 
 	if (!wma_is_vdev_up(vdev_id)) {
 		wma_err("vdev id %d is not up", vdev_id);

+ 3 - 6
core/wma/src/wma_scan_roam.c

@@ -2839,10 +2839,9 @@ int wma_extscan_wow_event_callback(void *handle, void *event, uint32_t len)
  */
 void wma_register_extscan_event_handler(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		wma_err("extscan wma_handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
+
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 					   wmi_extscan_start_stop_event_id,
 					   wma_extscan_start_stop_event_handler,
@@ -4791,10 +4790,8 @@ int wma_handle_btm_blacklist_event(void *handle, uint8_t *cmd_param_info,
 #if defined(WLAN_FEATURE_ROAM_OFFLOAD) && defined(WLAN_FEATURE_FIPS)
 void wma_register_pmkid_req_event_handler(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		wma_err("pmkid req wma_handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 					   wmi_roam_pmkid_request_event_id,

+ 21 - 48
core/wma/src/wma_twt.c

@@ -33,10 +33,9 @@ void wma_send_twt_enable_cmd(uint32_t pdev_id,
 	struct wmi_twt_enable_param twt_enable_params = {0};
 	int32_t ret;
 
-	if (!wma) {
-		wma_err("Invalid WMA context, enable TWT failed");
+	if (!wma)
 		return;
-	}
+
 	twt_enable_params.pdev_id = pdev_id;
 	twt_enable_params.sta_cong_timer_ms = congestion_timeout;
 	twt_enable_params.b_twt_enable = bcast_val;
@@ -64,19 +63,17 @@ int wma_twt_en_complete_event_handler(void *handle,
 	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
 	int status = -EINVAL;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle for TWT complete");
+	if (wma_validate_handle(wma_handle))
 		return status;
-	}
+
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
 		wma_err("Invalid wmi handle for TWT complete");
 		return status;
 	}
-	if (!mac) {
-		wma_err("Invalid MAC context");
+	if (!mac)
 		return status;
-	}
+
 	if (wmi_handle->ops->extract_twt_enable_comp_event)
 		status = wmi_handle->ops->extract_twt_enable_comp_event(
 								wmi_handle,
@@ -96,10 +93,9 @@ void wma_send_twt_disable_cmd(uint32_t pdev_id)
 	struct wmi_twt_disable_param twt_disable_params = {0};
 	int32_t ret;
 
-	if (!wma) {
-		wma_err("Invalid WMA context, Disable TWT failed");
+	if (!wma)
 		return;
-	}
+
 	twt_disable_params.pdev_id = pdev_id;
 	ret = wmi_unified_twt_disable_cmd(wma->wmi_handle, &twt_disable_params);
 
@@ -148,10 +144,8 @@ QDF_STATUS wma_twt_process_add_dialog(t_wma_handle *wma_handle,
 {
 	wmi_unified_t wmi_handle;
 
-	if (!wma_handle) {
-		wma_err("Invalid WMA context, twt add dialog failed");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -182,15 +176,11 @@ int wma_twt_add_dialog_complete_event_handler(void *handle,
 	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
 	int status = -EINVAL;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle for TWT add dialog complete");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
-	if (!mac) {
-		wma_err("Invalid MAC context");
+	if (!mac)
 		return -EINVAL;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -236,10 +226,8 @@ wma_twt_process_del_dialog(t_wma_handle *wma_handle,
 {
 	wmi_unified_t wmi_handle;
 
-	if (!wma_handle) {
-		wma_err("Invalid WMA context, twt del dialog failed");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -270,19 +258,16 @@ int wma_twt_del_dialog_complete_event_handler(void *handle,
 	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
 	int status = -EINVAL;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle for TWT del dialog complete");
+	if (wma_validate_handle(wma_handle))
 		return status;
-	}
+
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
 		wma_err("Invalid wma handle for TWT del dialog complete");
 		return status;
 	}
-	if (!mac) {
-		wma_err("Invalid MAC context");
+	if (!mac)
 		return status;
-	}
 
 	param = qdf_mem_malloc(sizeof(*param));
 	if (!param)
@@ -310,10 +295,8 @@ wma_twt_process_pause_dialog(t_wma_handle *wma_handle,
 {
 	wmi_unified_t wmi_handle;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle, twt pause dialog failed");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -344,15 +327,11 @@ int wma_twt_pause_dialog_complete_event_handler(void *handle, uint8_t *event,
 	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
 	int status = -EINVAL;
 
-	if (!mac) {
-		wma_err("Invalid MAC context");
+	if (!mac)
 		return status;
-	}
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle for TWT pause dialog complete");
+	if (wma_validate_handle(wma_handle))
 		return status;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -388,10 +367,8 @@ wma_twt_process_resume_dialog(t_wma_handle *wma_handle,
 {
 	wmi_unified_t wmi_handle;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle, twt resume dialog failed");
+	if (wma_validate_handle(wma_handle))
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -422,15 +399,11 @@ int wma_twt_resume_dialog_complete_event_handler(void *handle, uint8_t *event,
 	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
 	int status = -EINVAL;
 
-	if (!mac) {
-		wma_err("Invalid MAC context");
+	if (!mac)
 		return status;
-	}
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle for TWT resume dialog complete");
+	if (wma_validate_handle(wma_handle))
 		return status;
-	}
 
 	wmi_handle = (wmi_unified_t)wma_handle->wmi_handle;
 	if (!wmi_handle) {

+ 28 - 58
core/wma/src/wma_utils.c

@@ -2422,10 +2422,8 @@ static inline int wma_peer_ps_evt_handler(void *handle, u_int8_t *event,
  */
 void wma_register_ll_stats_event_handler(tp_wma_handle wma_handle)
 {
-	if (!wma_handle) {
-		wma_err("wma_handle is NULL");
+	if (wma_validate_handle(wma_handle))
 		return;
-	}
 
 	wmi_unified_register_event_handler(wma_handle->wmi_handle,
 				wmi_iface_link_stats_event_id,
@@ -3762,13 +3760,11 @@ bool wma_capability_enhanced_mcast_filter(void)
 bool wma_is_vdev_up(uint8_t vdev_id)
 {
 	struct wlan_objmgr_vdev *vdev;
-	tp_wma_handle wma = (tp_wma_handle)cds_get_context(QDF_MODULE_ID_WMA);
+	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 	bool is_up = false;
 
-	if (!wma) {
-		wma_err("WMA context is invalid!");
+	if (!wma)
 		return is_up;
-	}
 
 	vdev = wlan_objmgr_get_vdev_by_id_from_psoc(wma->psoc, vdev_id,
 			WLAN_LEGACY_WMA_ID);
@@ -4009,16 +4005,13 @@ int wma_chip_power_save_failure_detected_handler(void *handle,
 	WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID_param_tlvs *param_buf;
 	wmi_chip_power_save_failure_detected_fixed_param  *event;
 	struct chip_pwr_save_fail_detected_params  pwr_save_fail_params;
-	struct mac_context *mac = (struct mac_context *)cds_get_context(
-						QDF_MODULE_ID_PE);
-	if (!wma) {
-		wma_err("wma_handle is NULL");
+	struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE);
+	if (wma_validate_handle(wma))
 		return -EINVAL;
-	}
-	if (!mac) {
-		wma_err("Invalid mac context");
+
+	if (!mac)
 		return -EINVAL;
-	}
+
 	if (!mac->sme.chip_power_save_fail_cb) {
 		wma_err("Callback not registered");
 		return -EINVAL;
@@ -4062,10 +4055,8 @@ int wma_roam_scan_stats_event_handler(void *handle, uint8_t *event,
 	QDF_STATUS status;
 
 	wma_handle = handle;
-	if (!wma_handle) {
-		wma_err("NULL wma_handle");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
 	wmi_handle = wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -4194,10 +4185,9 @@ QDF_STATUS wma_sta_vdev_up_send(struct vdev_mlme_obj *vdev_mlme,
 	QDF_STATUS status;
 	struct wma_txrx_node *iface;
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
+
 	vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
 	iface = &wma->interfaces[vdev_id];
 	vdev_mlme->proto.sta.assoc_id = iface->aid;
@@ -4250,10 +4240,9 @@ QDF_STATUS wma_sta_mlme_vdev_start_continue(struct vdev_mlme_obj *vdev_mlme,
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 	enum vdev_assoc_type assoc_type;
 
-	if (!wma) {
-		wma_err("Invalid wma handle");
+	if (!wma)
 		return QDF_STATUS_E_FAILURE;
-	}
+
 	if (mlme_is_chan_switch_in_progress(vdev_mlme->vdev)) {
 		mlme_set_chan_switch_in_progress(vdev_mlme->vdev, false);
 		lim_process_switch_channel_rsp(wma->mac_context, data);
@@ -4284,10 +4273,8 @@ QDF_STATUS wma_sta_mlme_vdev_roam_notify(struct vdev_mlme_obj *vdev_mlme,
 	QDF_STATUS status = QDF_STATUS_SUCCESS;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	ret = wma_mlme_roam_synch_event_handler_cb(wma, data, data_len);
 	if (ret != 0) {
@@ -4307,10 +4294,8 @@ QDF_STATUS wma_ap_mlme_vdev_start_continue(struct vdev_mlme_obj *vdev_mlme,
 	uint8_t vdev_id;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	if (mlme_is_chan_switch_in_progress(vdev)) {
 		mlme_set_chan_switch_in_progress(vdev, false);
@@ -4339,10 +4324,8 @@ QDF_STATUS wma_ap_mlme_vdev_down_send(struct vdev_mlme_obj *vdev_mlme,
 {
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	wma_send_vdev_down(wma, data);
 
@@ -4368,7 +4351,6 @@ wma_mlme_vdev_notify_down_complete(struct vdev_mlme_obj *vdev_mlme,
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
 	if (!wma) {
-		wma_err("wma handle is NULL");
 		status = QDF_STATUS_E_INVAL;
 		goto end;
 	}
@@ -4410,10 +4392,8 @@ QDF_STATUS wma_ap_mlme_vdev_stop_start_send(struct vdev_mlme_obj *vdev_mlme,
 	struct add_bss_rsp *add_bss_rsp = data;
 
 	wma = cds_get_context(QDF_MODULE_ID_WMA);
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	if (wma_send_vdev_stop_to_fw(wma, add_bss_rsp->vdev_id))
 		wma_err("Failed to send vdev stop for vdev id %d",
@@ -4429,10 +4409,8 @@ QDF_STATUS wma_mon_mlme_vdev_start_continue(struct vdev_mlme_obj *vdev_mlme,
 {
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
 
 	if (mlme_is_chan_switch_in_progress(vdev_mlme->vdev))
 		mlme_set_chan_switch_in_progress(vdev_mlme->vdev, false);
@@ -4450,10 +4428,9 @@ QDF_STATUS wma_mon_mlme_vdev_up_send(struct vdev_mlme_obj *vdev_mlme,
 	QDF_STATUS status;
 	struct wma_txrx_node *iface;
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
+
 	vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
 	iface = &wma->interfaces[vdev_id];
 	vdev_mlme->proto.sta.assoc_id = 0;
@@ -4472,10 +4449,9 @@ QDF_STATUS wma_mon_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 	QDF_STATUS status;
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
+
 	vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
 
 	status = wma_send_vdev_stop_to_fw(wma, vdev_id);
@@ -4498,10 +4474,9 @@ QDF_STATUS wma_mon_mlme_vdev_down_send(struct vdev_mlme_obj *vdev_mlme,
 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
 	QDF_STATUS status;
 
-	if (!wma) {
-		wma_err("wma handle is NULL");
+	if (!wma)
 		return QDF_STATUS_E_INVAL;
-	}
+
 	vdev_id = wlan_vdev_get_id(vdev_mlme->vdev);
 
 	status = wma_send_vdev_down_to_fw(wma, vdev_id);
@@ -4528,10 +4503,8 @@ int wma_wlm_stats_req(int vdev_id, uint32_t bitmask, uint32_t max_size,
 	wmi_request_wlm_stats_cmd_fixed_param *cmd;
 	QDF_STATUS status;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (!wma_handle)
 		return -EINVAL;
-	}
 
 	wmi_handle = wma_handle->wmi_handle;
 	if (!wmi_handle) {
@@ -4584,10 +4557,9 @@ int wma_wlm_stats_rsp(void *wma_ctx, uint8_t *event, uint32_t evt_len)
 	uint32_t *raw_data;
 	uint32_t len, buffer_size, raw_data_num, i;
 
-	if (!wma_handle) {
-		wma_err("Invalid wma handle");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
+
 	if (!wma_handle->wlm_data.wlm_stats_callback) {
 		wma_err("No callback registered");
 		return -EINVAL;
@@ -4677,10 +4649,8 @@ int wma_cold_boot_cal_event_handler(void *wma_ctx, uint8_t *event_buff,
 	QDF_STATUS status;
 	tp_wma_handle wma_handle = (tp_wma_handle)wma_ctx;
 
-	if (!wma_handle) {
-		wma_err("NULL wma handle");
+	if (wma_validate_handle(wma_handle))
 		return -EINVAL;
-	}
 
 	param_buf =
 		   (WMI_PDEV_COLD_BOOT_CAL_DATA_EVENTID_param_tlvs *)event_buff;