Browse Source

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
Jeff Johnson 6 years ago
parent
commit
dc198eccdb

+ 6 - 6
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;
 	}

+ 3 - 3
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)
 {
 }

+ 3 - 3
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

+ 9 - 2
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,

+ 4 - 4
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)) {