From 3a08ff978a384cf8da97dff6964817e974b6c5c6 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Tue, 3 Jul 2018 19:40:44 -0700 Subject: [PATCH] qcacld-3.0: Refine the TWT callback APIs Currently the TWT enable complete and disable complete APIs specify a void pointer for the context parameter. It is fine for an API to use a void pointer for a data structure that is opaque or a binary blob, but in these cases an HDD handle is always passed, so explicitly reference that type. This will allow the compiler to verify that the correct type of parameter is being passed. Change-Id: Ibbe3f6809e892833473d234bf19a9245d7e7c1f1 CRs-Fixed: 2276989 --- core/hdd/inc/wlan_hdd_twt.h | 27 --------------------------- core/hdd/src/wlan_hdd_twt.c | 25 ++++++++++++++++++++----- core/sme/inc/sme_api.h | 35 ++++++++++++++++++----------------- core/sme/inc/sme_internal.h | 9 ++++++--- core/sme/src/common/sme_api.c | 21 ++++++++++----------- 5 files changed, 54 insertions(+), 63 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_twt.h b/core/hdd/inc/wlan_hdd_twt.h index 98d67b4a1b9d..7a181c75853f 100644 --- a/core/hdd/inc/wlan_hdd_twt.h +++ b/core/hdd/inc/wlan_hdd_twt.h @@ -90,24 +90,6 @@ void hdd_update_tgt_twt_cap(struct hdd_context *hdd_ctx, */ void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx); -/** - * hdd_twt_enable_comp_cb() - TWT enable complete event callback - * @hdd_ctx: pointer to global HDD Context - * @twt_event: TWT event data received from the target - * - * Return: None - */ -void hdd_twt_enable_comp_cb(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params); - -/** - * hdd_twt_disable_comp_cb() - TWT disable complete event callback - * @hdd_ctx: pointer to global HDD Context - * - * Return: None - */ -void hdd_twt_disable_comp_cb(void *hdd_ctx); - /** * wlan_hdd_twt_init() - Initialize TWT * @hdd_ctx: pointer to global HDD Context @@ -144,15 +126,6 @@ static inline void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx) { } -static inline void hdd_twt_enable_comp_cb(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params) -{ -} - -static inline void hdd_twt_disable_comp_cb(void *hdd_ctx) -{ -} - static inline void wlan_hdd_twt_init(struct hdd_context *hdd_ctx) { } diff --git a/core/hdd/src/wlan_hdd_twt.c b/core/hdd/src/wlan_hdd_twt.c index d63ae5bdbdb8..7d1250826ac2 100644 --- a/core/hdd/src/wlan_hdd_twt.c +++ b/core/hdd/src/wlan_hdd_twt.c @@ -79,10 +79,18 @@ void hdd_send_twt_enable_cmd(struct hdd_context *hdd_ctx) wma_send_twt_enable_cmd(pdev_id, congestion_timeout); } -void hdd_twt_enable_comp_cb(void *hddctx, - struct wmi_twt_enable_complete_event_param *params) +/** + * hdd_twt_enable_comp_cb() - TWT enable complete event callback + * @hdd_handle: opaque handle for the global HDD Context + * @twt_event: TWT event data received from the target + * + * Return: None + */ +static void +hdd_twt_enable_comp_cb(hdd_handle_t hdd_handle, + struct wmi_twt_enable_complete_event_param *params) { - struct hdd_context *hdd_ctx = hddctx; + struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); enum twt_status prev_state; if (!hdd_ctx) { @@ -112,9 +120,16 @@ void hdd_twt_enable_comp_cb(void *hddctx, prev_state, hdd_ctx->twt_state); } -void hdd_twt_disable_comp_cb(void *hddctx) +/** + * hdd_twt_disable_comp_cb() - TWT disable complete event callback + * @hdd_handle: opaque handle for the global HDD Context + * + * Return: None + */ +static void +hdd_twt_disable_comp_cb(hdd_handle_t hdd_handle) { - struct hdd_context *hdd_ctx = hddctx; + struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); enum twt_status prev_state; if (!hdd_ctx) { diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index e6e3183fea0e..2107ba2251bf 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -2490,25 +2490,23 @@ uint8_t sme_get_mcs_idx(uint16_t max_rate, uint8_t rate_flags, #ifdef WLAN_SUPPORT_TWT /** * sme_register_twt_enable_complete_cb() - TWT enable registrar - * @hal: HAL handle + * @mac_handle: MAC handle * @twt_enable_cb: Function callback to handle enable event - * @hdd_ctx: Global HDD Context * * Return: QDF Status */ -QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal, - void (*twt_enable_cb)(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params)); +QDF_STATUS sme_register_twt_enable_complete_cb(mac_handle_t mac_handle, + twt_enable_cb twt_enable_cb); /** * sme_register_twt_disable_complete_cb - TWT disable registrar - * @hal: HAL handle + * @mac_handle: MAC handle * @twt_disable_cb: Function callback to handle disable event * * Return: QDF Status */ -QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal, - void (*twt_disable_cb)(void *hdd_ctx)); +QDF_STATUS sme_register_twt_disable_complete_cb(mac_handle_t mac_handle, + twt_disable_cb twt_disable_cb); /** * sme_deregister_twt_enable_complete_cb() - TWT enable deregistrar @@ -2516,7 +2514,7 @@ QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal, * * Return: QDF Status */ -QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal); +QDF_STATUS sme_deregister_twt_enable_complete_cb(mac_handle_t mac_handle); /** * sme_deregister_twt_disable_complete_cb - TWT disable deregistrar @@ -2524,28 +2522,31 @@ QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal); * * Return: QDF Status */ -QDF_STATUS sme_deregister_twt_disable_complete_cb(tHalHandle hal); +QDF_STATUS sme_deregister_twt_disable_complete_cb(mac_handle_t mac_handle); #else -static inline QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal, - void (*twt_enable_cb)(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params)) +static inline +QDF_STATUS sme_register_twt_enable_complete_cb(mac_handle_t mac_handle, + twt_enable_cb twt_enable_cb) { return QDF_STATUS_SUCCESS; } -static inline QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal, - void (*twt_disable_cb)(void *hdd_ctx)) +static inline +QDF_STATUS sme_register_twt_disable_complete_cb(mac_handle_t mac_handle, + twt_disable_cb twt_disable_cb) { return QDF_STATUS_SUCCESS; } -static inline QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal) +static inline +QDF_STATUS sme_deregister_twt_enable_complete_cb(mac_handle_t mac_handle) { return QDF_STATUS_SUCCESS; } -static inline QDF_STATUS sme_deregister_twt_disable_complete_cb(tHalHandle hal) +static inline +QDF_STATUS sme_deregister_twt_disable_complete_cb(mac_handle_t mac_handle) { return QDF_STATUS_SUCCESS; } diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h index c9b4999e3042..3355a7dc59e6 100644 --- a/core/sme/inc/sme_internal.h +++ b/core/sme/inc/sme_internal.h @@ -127,6 +127,10 @@ typedef void (*p2p_lo_callback)(void *context, void *event); typedef void (*sme_send_oem_data_rsp_msg)(struct oem_data_rsp *); #endif +typedef void (*twt_enable_cb)(hdd_handle_t hdd_handle, + struct wmi_twt_enable_complete_event_param *params); +typedef void (*twt_disable_cb)(hdd_handle_t hdd_handle); + #ifdef FEATURE_WLAN_APF /** * typedef apf_get_offload_cb - APF offload callback signature @@ -284,9 +288,8 @@ typedef struct tagSmeStruct { void (*tx_queue_cb)(void *, uint32_t vdev_id, enum netif_action_type action, enum netif_reason_type reason); - void (*twt_enable_cb)(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params); - void (*twt_disable_cb)(void *hdd_ctx); + twt_enable_cb twt_enable_cb; + twt_disable_cb twt_disable_cb; #ifdef FEATURE_WLAN_APF apf_get_offload_cb apf_get_offload_cb; apf_read_mem_cb apf_read_mem_cb; diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 05fab2db58c6..a912c7bd49f1 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -15435,12 +15435,11 @@ QDF_STATUS sme_deregister_tx_queue_cb(tHalHandle hal) } #ifdef WLAN_SUPPORT_TWT -QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal, - void (*twt_enable_cb)(void *hdd_ctx, - struct wmi_twt_enable_complete_event_param *params)) +QDF_STATUS sme_register_twt_enable_complete_cb(mac_handle_t mac_handle, + twt_enable_cb twt_enable_cb) { QDF_STATUS status; - tpAniSirGlobal mac = PMAC_STRUCT(hal); + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); status = sme_acquire_global_lock(&mac->sme); if (QDF_IS_STATUS_SUCCESS(status)) { @@ -15454,11 +15453,11 @@ QDF_STATUS sme_register_twt_enable_complete_cb(tHalHandle hal, return status; } -QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal, - void (*twt_disable_cb)(void *hdd_ctx)) +QDF_STATUS sme_register_twt_disable_complete_cb(mac_handle_t mac_handle, + twt_disable_cb twt_disable_cb) { QDF_STATUS status; - tpAniSirGlobal mac = PMAC_STRUCT(hal); + tpAniSirGlobal mac = MAC_CONTEXT(mac_handle); status = sme_acquire_global_lock(&mac->sme); if (QDF_IS_STATUS_SUCCESS(status)) { @@ -15472,14 +15471,14 @@ QDF_STATUS sme_register_twt_disable_complete_cb(tHalHandle hal, return status; } -QDF_STATUS sme_deregister_twt_enable_complete_cb(tHalHandle hal) +QDF_STATUS sme_deregister_twt_enable_complete_cb(mac_handle_t mac_handle) { - return sme_register_twt_enable_complete_cb(hal, NULL); + return sme_register_twt_enable_complete_cb(mac_handle, NULL); } -QDF_STATUS sme_deregister_twt_disable_complete_cb(tHalHandle hal) +QDF_STATUS sme_deregister_twt_disable_complete_cb(mac_handle_t mac_handle) { - return sme_register_twt_disable_complete_cb(hal, NULL); + return sme_register_twt_disable_complete_cb(mac_handle, NULL); } #endif