From f6182e45612a88fca9366966d5c7ecf95350d255 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Tue, 3 Jul 2018 14:46:17 -0700 Subject: [PATCH] qcacld-3.0: Refine the congestion_cb API Currently the congestion_cb API specifies 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 this case 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: I3bfa07300fad8cd75b7b98c9b7ccdad4936bf32f CRs-Fixed: 2276476 --- core/hdd/src/wlan_hdd_cfg80211.c | 4 ++-- core/hdd/src/wlan_hdd_cfg80211.h | 10 +++++----- core/sme/inc/sme_api.h | 4 ++-- core/sme/inc/sme_internal.h | 11 ++++++++++- core/sme/src/common/sme_api.c | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 62fd69761584..dc4698b533a4 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -12492,10 +12492,10 @@ end: return err; } -void hdd_update_cca_info_cb(void *context, uint32_t congestion, +void hdd_update_cca_info_cb(hdd_handle_t hdd_handle, uint32_t congestion, uint32_t vdev_id) { - 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 = NULL; struct hdd_station_ctx *hdd_sta_ctx; diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h index 2a8db153a0f7..ad449dc7fb1b 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.h +++ b/core/hdd/src/wlan_hdd_cfg80211.h @@ -520,14 +520,14 @@ int wlan_hdd_disconnect(struct hdd_adapter *adapter, u16 reason); /** * hdd_update_cca_info_cb() - stores congestion value in station context - * @context : HDD context - * @congestion : congestion - * @vdev_id : vdev id + * @hdd_handle: HDD handle + * @congestion: congestion + * @vdev_id: vdev id * * Return: None */ -void hdd_update_cca_info_cb(void *context, uint32_t congestion, - uint32_t vdev_id); +void hdd_update_cca_info_cb(hdd_handle_t hdd_handle, uint32_t congestion, + uint32_t vdev_id); /** * wlan_hdd_get_adjacent_chan(): Gets next/previous channel diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index 107bbf37bc61..7f6685da1f47 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -1706,14 +1706,14 @@ QDF_STATUS sme_fast_reassoc(tHalHandle hal, struct csr_roam_profile *profile, uint8_t vdev_id, const tSirMacAddr connected_bssid); #endif /** - * sme_congestion_register_callback(): registers congestion callback + * sme_congestion_register_callback() - registers congestion callback * @hal: handler for HAL * @congestion_cb: congestion callback * * Return: QDF_STATUS */ QDF_STATUS sme_congestion_register_callback(tHalHandle hal, - void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id)); + congestion_cb congestion_cb); /** * sme_register_tx_queue_cb(): Register tx queue callback diff --git a/core/sme/inc/sme_internal.h b/core/sme/inc/sme_internal.h index c412d4ed87eb..2ba17393fc74 100644 --- a/core/sme/inc/sme_internal.h +++ b/core/sme/inc/sme_internal.h @@ -176,6 +176,15 @@ struct chip_pwr_save_fail_detected_params; typedef void (*pwr_save_fail_cb)(hdd_handle_t hdd_handle, struct chip_pwr_save_fail_detected_params *params); +/** + * typedef congestion_cb - congestion callback function + * @hdd_handle: HDD handle registered with SME + * @congestion: Current congestion value + * @vdev_id: ID of the vdev for which congestion is being reported + */ +typedef void (*congestion_cb)(hdd_handle_t hdd_handle, uint32_t congestion, + uint32_t vdev_id); + typedef struct tagSmeStruct { eSmeState state; qdf_mutex_t lkSmeGlobalLock; @@ -261,7 +270,7 @@ typedef struct tagSmeStruct { enum scan_reject_states *reason); void (*rso_cmd_status_cb)(void *hdd_context, struct rso_cmd_status *rso_status); - void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id); + congestion_cb congestion_cb; void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *); pwr_save_fail_cb chip_power_save_fail_cb; void (*bt_activity_info_cb)(void *context, uint32_t bt_activity); diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index c68e06368d9d..fd227cb7552f 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -15398,7 +15398,7 @@ void sme_store_pdev(tHalHandle hal, struct wlan_objmgr_pdev *pdev) } QDF_STATUS sme_congestion_register_callback(tHalHandle hal, - void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id)) + congestion_cb congestion_cb) { QDF_STATUS status; tpAniSirGlobal mac = PMAC_STRUCT(hal);