Browse Source

qcacld-3.0: Refine the NAN Event callback API

The NAN Event callback currently specifies a void pointer for the
context. In the case of this API the context is actually known to be
an HDD handle, so update the API to explicitly use this type. This
will allow the compiler to verify that the correct type of parameter
is being passed.

Change-Id: I998119cb02d2b6412b63c36f740016745a6fbe4f
CRs-Fixed: 2278582
Jeff Johnson 6 years ago
parent
commit
c45168b885

+ 16 - 4
core/hdd/inc/wlan_hdd_nan.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -63,7 +63,19 @@ static inline void hdd_nan_populate_pmo_config(struct pmo_psoc_cfg *pmo_cfg,
 	pmo_cfg->nan_enable = hdd_ctx->config->enable_nan_support;
 }
 
-void wlan_hdd_cfg80211_nan_callback(void *ctx, tSirNanEvent *msg);
+/**
+ * wlan_hdd_cfg80211_nan_callback() - cfg80211 NAN event handler
+ * @hdd_handle: opaque handle to the global HDD context
+ * @msg: NAN event message
+ *
+ * This is a callback function and it gets called when we need to report
+ * a nan event to userspace.  The wlan host driver simply encapsulates the
+ * event into a netlink payload and then forwards it to userspace via a
+ * cfg80211 vendor event.
+ *
+ * Return: nothing
+ */
+void wlan_hdd_cfg80211_nan_callback(hdd_handle_t hdd_handle, tSirNanEvent *msg);
 #else
 static inline bool wlan_hdd_nan_is_supported(void)
 {
@@ -79,8 +91,8 @@ static inline void hdd_nan_populate_pmo_config(struct pmo_psoc_cfg *pmo_cfg,
 {
 }
 
-static inline void wlan_hdd_cfg80211_nan_callback(void *ctx,
-						  tSirNanEvent *msg)
+static inline
+void wlan_hdd_cfg80211_nan_callback(hdd_handle_t hdd_handle, tSirNanEvent *msg)
 {
 }
 #endif /* WLAN_FEATURE_NAN */

+ 3 - 15
core/hdd/src/wlan_hdd_nan.c

@@ -110,25 +110,13 @@ int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
 	return ret;
 }
 
-/**
- * wlan_hdd_cfg80211_nan_callback() - cfg80211 NAN event handler
- * @ctx: global HDD context
- * @msg: NAN event message
- *
- * This is a callback function and it gets called when we need to report
- * a nan event to userspace.  The wlan host driver simply encapsulates the
- * event into a netlink payload and then forwards it to userspace via a
- * cfg80211 vendor event.
- *
- * Return: nothing
- */
-void wlan_hdd_cfg80211_nan_callback(void *ctx, tSirNanEvent *msg)
+void wlan_hdd_cfg80211_nan_callback(hdd_handle_t hdd_handle, tSirNanEvent *msg)
 {
-	struct hdd_context *hdd_ctx = ctx;
+	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
 	struct sk_buff *vendor_event;
 	int status;
 
-	if (NULL == msg) {
+	if (!msg) {
 		hdd_err("msg received here is null");
 		return;
 	}

+ 3 - 2
core/sme/inc/nan_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016, 2018 The Linux Foundation. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -28,8 +28,9 @@
 #define __NAN_API_H__
 
 #include "qdf_types.h"
+#include "sir_types.h"
 
-typedef void (*nan_callback)(void *, tSirNanEvent *);
+typedef void (*nan_callback)(hdd_handle_t hdd_handle, tSirNanEvent *event);
 
 #ifdef WLAN_FEATURE_NAN
 typedef struct sNanRequestReq {

+ 3 - 1
core/sme/inc/sme_internal.h

@@ -36,6 +36,8 @@
 #include "host_diag_core_event.h"
 #include "csr_link_list.h"
 #include "sme_power_save.h"
+#include "nan_api.h"
+
 struct wmi_twt_enable_complete_event_param;
 /*--------------------------------------------------------------------------
   Type declarations
@@ -273,7 +275,7 @@ typedef struct tagSmeStruct {
 	ext_scan_ind_cb ext_scan_ind_cb;
 #endif /* FEATURE_WLAN_EXTSCAN */
 #ifdef WLAN_FEATURE_NAN
-	void (*nanCallback)(void *, tSirNanEvent *);
+	nan_callback nan_callback;
 #endif
 	bool enableSelfRecovery;
 	tCsrLinkStatusCallback linkStatusCallback;

+ 4 - 4
core/sme/src/nan/nan_api.c

@@ -45,7 +45,7 @@ void sme_nan_register_callback(tHalHandle hHal, nan_callback callback)
 		return;
 	}
 	pMac = PMAC_STRUCT(hHal);
-	pMac->sme.nanCallback = callback;
+	pMac->sme.nan_callback = callback;
 }
 
 /**
@@ -66,7 +66,7 @@ void sme_nan_deregister_callback(tHalHandle h_hal)
 		return;
 	}
 	pmac = PMAC_STRUCT(h_hal);
-	pmac->sme.nanCallback = NULL;
+	pmac->sme.nan_callback = NULL;
 }
 
 
@@ -136,8 +136,8 @@ QDF_STATUS sme_nan_event(tHalHandle hHal, void *pMsg)
 	} else {
 		QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
 			  FL("SME: Received sme_nan_event"));
-		if (pMac->sme.nanCallback) {
-			pMac->sme.nanCallback(pMac->hdd_handle,
+		if (pMac->sme.nan_callback) {
+			pMac->sme.nan_callback(pMac->hdd_handle,
 					      (tSirNanEvent *) pMsg);
 		}
 	}