Bladeren bron

qcacld-3.0: Introduce wma_validate_handle()

Introduce wma_validate_handle() with the caller function name
embedded in it to validate the WMA handle and log incase
of error. Calling functions can avoid logging in case
wma_validate_handle() returns -EINVAL. This reduces logging and
thereby memory foot print.

Change-Id: If38436a590d8b950509bde40468b9ddc3cf33e8d
CRs-Fixed: 2833040
Srinivas Girigowda 4 jaren geleden
bovenliggende
commit
328cdc189c
2 gewijzigde bestanden met toevoegingen van 20 en 0 verwijderingen
  1. 10 0
      core/wma/inc/wma.h
  2. 10 0
      core/wma/src/wma_main.c

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

@@ -1040,6 +1040,16 @@ typedef struct {
 	bool enable_tx_compl_tsf64;
 } t_wma_handle, *tp_wma_handle;
 
+/**
+ * wma_validate_handle() - Validate WMA handle
+ * @wma_handle: wma handle
+ *
+ * Return: errno if WMA handle is NULL; 0 otherwise
+ */
+#define wma_validate_handle(wma_handle) \
+        __wma_validate_handle(wma_handle, __func__)
+int __wma_validate_handle(tp_wma_handle wma_handle, const char *func);
+
 /**
  * wma_vdev_nss_chain_params_send() - send vdev nss chain params to fw.
  * @vdev_id: vdev_id

+ 10 - 0
core/wma/src/wma_main.c

@@ -177,6 +177,16 @@ struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma)
 	return &wma->ini_config;
 }
 
+int __wma_validate_handle(tp_wma_handle wma_handle, const char *func)
+{
+	if (!wma_handle) {
+		wma_err("Invalid WMA handle (via %s)", func);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 #define MAX_SUPPORTED_PEERS_REV1_1 14
 #define MAX_SUPPORTED_PEERS_REV1_3 32
 #ifdef WLAN_MAX_CLIENTS_ALLOWED