From c45168b8858c9a0dfa64e366ae4de1bf11ded212 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Wed, 4 Jul 2018 14:23:08 -0700 Subject: [PATCH] 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 --- core/hdd/inc/wlan_hdd_nan.h | 20 ++++++++++++++++---- core/hdd/src/wlan_hdd_nan.c | 18 +++--------------- core/sme/inc/nan_api.h | 5 +++-- core/sme/inc/sme_internal.h | 4 +++- core/sme/src/nan/nan_api.c | 8 ++++---- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_nan.h b/core/hdd/inc/wlan_hdd_nan.h index 919e2222bf34..25505713c6de 100644 --- a/core/hdd/inc/wlan_hdd_nan.h +++ b/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 */ diff --git a/core/hdd/src/wlan_hdd_nan.c b/core/hdd/src/wlan_hdd_nan.c index 4a1cf1700c88..eb646052e7a0 100644 --- a/core/hdd/src/wlan_hdd_nan.c +++ b/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; } diff --git a/core/sme/inc/nan_api.h b/core/sme/inc/nan_api.h index 8ef30a0b5567..eb63cb2b5073 100644 --- a/core/sme/inc/nan_api.h +++ b/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 { diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h index a25cc2ba1b31..48b2df496abb 100644 --- a/core/sme/inc/sme_internal.h +++ b/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; diff --git a/core/sme/src/nan/nan_api.c b/core/sme/src/nan/nan_api.c index 6496d85d24c3..6defdeea4eeb 100644 --- a/core/sme/src/nan/nan_api.c +++ b/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); } }