Kaynağa Gözat

qcacld-3.0: Refine the chip_power_save_fail_cb API

Currently the chip_power_save_fail_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: Ia9cbf1a229423d3dffd4d137c726d34b7a70fbb3
CRs-Fixed: 2276467
Jeff Johnson 6 yıl önce
ebeveyn
işleme
b7fa256b6c

+ 2 - 2
core/hdd/inc/wlan_hdd_main.h

@@ -3057,7 +3057,7 @@ void hdd_start_complete(int ret);
 /**
  * hdd_chip_pwr_save_fail_detected_cb() - chip power save failure detected
  * callback
- * @hddctx: HDD context
+ * @hdd_handle: HDD handle
  * @data: chip power save failure detected data
  *
  * This function reads the chip power save failure detected data and fill in
@@ -3068,7 +3068,7 @@ void hdd_start_complete(int ret);
  * Return: none
  */
 
-void hdd_chip_pwr_save_fail_detected_cb(void *hddctx,
+void hdd_chip_pwr_save_fail_detected_cb(hdd_handle_t hdd_handle,
 				struct chip_pwr_save_fail_detected_params
 				*data);
 

+ 3 - 15
core/hdd/src/wlan_hdd_cfg80211.c

@@ -4025,24 +4025,12 @@ wlan_hdd_cfg80211_set_ext_roam_params(struct wiphy *wiphy,
 
 #define PWR_SAVE_FAIL_CMD_INDEX \
 	QCA_NL80211_VENDOR_SUBCMD_PWR_SAVE_FAIL_DETECTED_INDEX
-/**
- * hdd_chip_pwr_save_fail_detected_cb() - chip power save failure detected
- * callback
- * @hddctx: HDD context
- * @data: chip power save failure detected data
- *
- * This function reads the chip power save failure detected data and fill in
- * the skb with NL attributes and send up the NL event.
- * This callback execute in atomic context and must not invoke any
- * blocking calls.
- *
- * Return: none
- */
-void hdd_chip_pwr_save_fail_detected_cb(void *hddctx,
+
+void hdd_chip_pwr_save_fail_detected_cb(hdd_handle_t hdd_handle,
 			struct chip_pwr_save_fail_detected_params
 			*data)
 {
-	struct hdd_context *hdd_ctx	= hddctx;
+	struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle);
 	struct sk_buff *skb;
 	int flags = cds_get_gfp_flags();
 

+ 4 - 4
core/sme/inc/sme_api.h

@@ -1834,9 +1834,9 @@ QDF_STATUS sme_set_rx_set_blocksize(tHalHandle hal,
  */
 QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi);
 
-/*
+/**
  * sme_set_chip_pwr_save_fail_cb() - set chip power save failure callback
- * @hal: global hal handle
+ * @mac_handle: opaque handle to the MAC context
  * @cb: callback function pointer
  *
  * This function stores the chip power save failure callback function.
@@ -1844,8 +1844,8 @@ QDF_STATUS sme_get_rcpi(tHalHandle hal, struct sme_rcpi_req *rcpi);
  * Return: QDF_STATUS enumeration.
  */
 
-QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal, void (*cb)(void *,
-				 struct chip_pwr_save_fail_detected_params *));
+QDF_STATUS sme_set_chip_pwr_save_fail_cb(mac_handle_t mac_handle,
+					 pwr_save_fail_cb cb);
 /**
  * sme_cli_set_command() - SME wrapper API over WMA "set" command
  * processor cmd

+ 10 - 2
core/sme/inc/sme_internal.h

@@ -167,6 +167,15 @@ struct chain_rssi_result;
 typedef void (*get_chain_rssi_callback)(void *context,
 					struct chain_rssi_result *data);
 
+/**
+ * typedef pwr_save_fail_cb - power save fail callback function
+ * @hdd_handle: HDD handle registered with SME
+ * @params: failure parameters
+ */
+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 struct tagSmeStruct {
 	eSmeState state;
 	qdf_mutex_t lkSmeGlobalLock;
@@ -254,8 +263,7 @@ typedef struct tagSmeStruct {
 			struct rso_cmd_status *rso_status);
 	void (*congestion_cb)(void *, uint32_t congestion, uint32_t vdev_id);
 	void (*stats_ext2_cb)(void *, struct sir_sme_rx_aggr_hole_ind *);
-	void (*chip_power_save_fail_cb)(void *,
-			struct chip_pwr_save_fail_detected_params *);
+	pwr_save_fail_cb chip_power_save_fail_cb;
 	void (*bt_activity_info_cb)(void *context, uint32_t bt_activity);
 	void *get_arp_stats_context;
 	void (*get_arp_stats_cb)(void *, struct rsp_stats *, void *);

+ 5 - 6
core/sme/src/common/sme_api.c

@@ -13073,12 +13073,11 @@ bool sme_is_any_session_in_connected_state(tHalHandle h_hal)
 	return ret;
 }
 
-QDF_STATUS sme_set_chip_pwr_save_fail_cb(tHalHandle hal,
-		 void (*cb)(void *,
-		 struct chip_pwr_save_fail_detected_params *)) {
-
-	QDF_STATUS status  = QDF_STATUS_SUCCESS;
-	tpAniSirGlobal mac = PMAC_STRUCT(hal);
+QDF_STATUS sme_set_chip_pwr_save_fail_cb(mac_handle_t mac_handle,
+					 pwr_save_fail_cb cb)
+{
+	QDF_STATUS status;
+	tpAniSirGlobal mac = MAC_CONTEXT(mac_handle);
 
 	status = sme_acquire_global_lock(&mac->sme);
 	if (status != QDF_STATUS_SUCCESS) {