From dc198eccdb61076d71210856467b2ffc1530a3ed Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Wed, 4 Jul 2018 17:39:53 -0700 Subject: [PATCH] qcacld-3.0: Refine the Lost Link Info callback API The Lost Link Info 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: I1ef9151d1a0c444a9bbb64aee6ae26030dd0bdbf CRs-Fixed: 2278585 --- core/hdd/src/wlan_hdd_stats.c | 12 ++++++------ core/hdd/src/wlan_hdd_stats.h | 6 +++--- core/sme/inc/sme_api.h | 6 +++--- core/sme/inc/sme_internal.h | 11 +++++++++-- core/sme/src/common/sme_api.c | 8 ++++---- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index 42e34f14c6a5..a6ea212740fe 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -1169,24 +1169,24 @@ void wlan_hdd_cfg80211_link_layer_stats_callback(hdd_handle_t hdd_handle, } } -void hdd_lost_link_info_cb(void *context, - struct sir_lost_link_info *lost_link_info) +void hdd_lost_link_info_cb(hdd_handle_t hdd_handle, + struct sir_lost_link_info *lost_link_info) { - struct hdd_context *hdd_ctx = (struct hdd_context *)context; + struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); int status; struct hdd_adapter *adapter; status = wlan_hdd_validate_context(hdd_ctx); - if (0 != status) + if (status) return; - if (NULL == lost_link_info) { + if (!lost_link_info) { hdd_err("lost_link_info is NULL"); return; } adapter = hdd_get_adapter_by_vdev(hdd_ctx, lost_link_info->vdev_id); - if (NULL == adapter) { + if (!adapter) { hdd_err("invalid adapter"); return; } diff --git a/core/hdd/src/wlan_hdd_stats.h b/core/hdd/src/wlan_hdd_stats.h index 4d3309198995..2841ad73da89 100644 --- a/core/hdd/src/wlan_hdd_stats.h +++ b/core/hdd/src/wlan_hdd_stats.h @@ -220,12 +220,12 @@ void wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx, /** * hdd_lost_link_info_cb() - callback function to get lost link information - * @context: HDD context + * @hdd_handle: Opaque handle for the HDD context * @lost_link_info: lost link information * * Return: none */ -void hdd_lost_link_info_cb(void *context, +void hdd_lost_link_info_cb(hdd_handle_t hdd_handle, struct sir_lost_link_info *lost_link_info); #else /* WLAN_FEATURE_LINK_LAYER_STATS */ @@ -274,7 +274,7 @@ wlan_hdd_cfg80211_link_layer_stats_ext_callback(hdd_handle_t ctx, } static inline void -hdd_lost_link_info_cb(void *context, +hdd_lost_link_info_cb(hdd_handle_t hdd_handle, struct sir_lost_link_info *lost_link_info) { } diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index d15825dc3b6e..c9af88c03411 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1635,13 +1635,13 @@ QDF_STATUS sme_update_sta_inactivity_timeout(tHalHandle hal_handle, /** * sme_set_lost_link_info_cb() - plug in callback function for receiving - * @hal: HAL handle + * @mac_handle: Opaque handle to the MAC context * @cb: callback function * * Return: HAL status */ -QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal, - void (*cb)(void *, struct sir_lost_link_info *)); +QDF_STATUS sme_set_lost_link_info_cb(mac_handle_t mac_handle, + lost_link_info_cb cb); /** * sme_update_new_channel_event() - update new channel event for sapFsm diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h index 212599398cbb..07255eeb8aaa 100644 --- a/core/sme/inc/sme_internal.h +++ b/core/sme/inc/sme_internal.h @@ -248,6 +248,14 @@ typedef void (*congestion_cb)(hdd_handle_t hdd_handle, uint32_t congestion, typedef void (*rso_cmd_status_cb)(hdd_handle_t hdd_handle, struct rso_cmd_status *rso_status); +/** + * typedef lost_link_info_cb - lost link indication callback function + * @hdd_handle: HDD handle registered with SME + * @lost_link_info: Information about the lost link + */ +typedef void (*lost_link_info_cb)(hdd_handle_t hdd_handle, + struct sir_lost_link_info *lost_link_info); + typedef struct tagSmeStruct { eSmeState state; qdf_mutex_t lkSmeGlobalLock; @@ -325,8 +333,7 @@ typedef struct tagSmeStruct { #endif sme_encrypt_decrypt_callback encrypt_decrypt_cb; void *encrypt_decrypt_context; - void (*lost_link_info_cb)(void *context, - struct sir_lost_link_info *lost_link_info); + lost_link_info_cb lost_link_info_cb; bool (*set_connection_info_cb)(bool); bool (*get_connection_info_cb)(uint8_t *session_id, diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index d49167524ca5..f95869e02e4a 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -14661,11 +14661,11 @@ QDF_STATUS sme_update_tx_fail_cnt_threshold(tHalHandle hal_handle, return status; } -QDF_STATUS sme_set_lost_link_info_cb(tHalHandle hal, - void (*cb)(void *, struct sir_lost_link_info *)) +QDF_STATUS sme_set_lost_link_info_cb(mac_handle_t mac_handle, + lost_link_info_cb cb) { - QDF_STATUS status = QDF_STATUS_SUCCESS; - tpAniSirGlobal mac = PMAC_STRUCT(hal); + QDF_STATUS status; + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); status = sme_acquire_global_lock(&mac->sme); if (QDF_IS_STATUS_SUCCESS(status)) {