Explorar o código

qcacmn: Introduce wmi_validate_handle()

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

Change-Id: Ie0a6a84ffad6e5cf2da8f547c7209dc77cdf5729
CRs-Fixed: 2838960
Srinivas Girigowda %!s(int64=4) %!d(string=hai) anos
pai
achega
7db601e3af
Modificáronse 2 ficheiros con 23 adicións e 0 borrados
  1. 13 0
      wmi/inc/wmi_unified_api.h
  2. 10 0
      wmi/src/wmi_unified.c

+ 13 - 0
wmi/inc/wmi_unified_api.h

@@ -4249,4 +4249,17 @@ QDF_STATUS wmi_extract_pdev_csa_switch_count_status(
 		wmi_unified_t wmi_handle,
 		void *evt_buf,
 		struct pdev_csa_switch_count_status *param);
+
+/**
+ * wmi_validate_handle() - Validate WMI handle
+ * @wmi_handle: wmi handle
+ *
+ * This function will log on error and hence caller should not log on error
+ *
+ * Return: errno if WMI handle is NULL; 0 otherwise
+ */
+#define wmi_validate_handle(wmi_handle) \
+        __wmi_validate_handle(wmi_handle, __func__)
+int __wmi_validate_handle(wmi_unified_t wmi_handle, const char *func);
+
 #endif /* _WMI_UNIFIED_API_H_ */

+ 10 - 0
wmi/src/wmi_unified.c

@@ -3639,3 +3639,13 @@ void wmi_pdev_id_conversion_enable(wmi_unified_t wmi_handle,
 							       pdev_id_map,
 							       size);
 }
+
+int __wmi_validate_handle(wmi_unified_t wmi_handle, const char *func)
+{
+        if (!wmi_handle) {
+                wmi_err("Invalid WMI handle (via %s)", func);
+                return -EINVAL;
+        }
+
+        return 0;
+}