diff options
| author | Dundi Raviteja <dundi@codeaurora.org> | 2018-04-25 18:10:24 +0530 |
|---|---|---|
| committer | nshrivas <nshrivas@codeaurora.org> | 2018-05-04 04:36:02 -0700 |
| commit | 8aad315ad21280b135f34bc202249ca287c63ed3 (patch) | |
| tree | 76701411aaed491a28f2e4983eb3a2ea33bfd445 | |
| parent | 776c600ae88d22d93577e836f574a0e96ca919fe (diff) | |
qcacld-3.0: Use request manager for temperature
We are transitioning to the new request manager framework.
Change wlan_hdd_get_temperature() and hdd_get_temperature_cb()
to this framework.
Change-Id: I01d0ce6d1f23b3c4bddc69d4ee1498408cb50b6c
CRs-Fixed: 2005306
| -rw-r--r-- | core/hdd/inc/wlan_hdd_main.h | 1 | ||||
| -rw-r--r-- | core/hdd/src/wlan_hdd_wext.c | 89 |
2 files changed, 53 insertions, 37 deletions
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index aa3df6c23ffd..0c801e50615b 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -448,7 +448,6 @@ extern struct mutex hdd_init_deinit_lock; #define POWER_CONTEXT_MAGIC 0x504F5752 /* POWR */ #define SNR_CONTEXT_MAGIC 0x534E5200 /* SNR */ #define LINK_STATUS_MAGIC 0x4C4B5354 /* LINKSTATUS(LNST) */ -#define TEMP_CONTEXT_MAGIC 0x74656d70 /* TEMP (temperature) */ #define APF_CONTEXT_MAGIC 0x4575354 /* APF */ #define POWER_STATS_MAGIC 0x14111990 #define RCPI_CONTEXT_MAGIC 0x7778888 /* RCPI */ diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 1269a0978f5c..105090af52de 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -7205,10 +7205,14 @@ free: return retval; } +struct temperature_priv { + int temperature; +}; + /** * hdd_get_temperature_cb() - "Get Temperature" callback function * @temperature: measured temperature - * @pContext: callback context + * @context: callback context * * This function is passed to sme_get_temperature() as the callback * function to be invoked when the temperature measurement is @@ -7216,30 +7220,24 @@ free: * * Return: None */ -static void hdd_get_temperature_cb(int temperature, void *pContext) +static void hdd_get_temperature_cb(int temperature, void *context) { - struct statsContext *pTempContext; - hdd_adapter_t *pAdapter; + struct hdd_request *request; + struct temperature_priv *priv; ENTER(); - if (NULL == pContext) { - hdd_err("pContext is NULL"); - return; - } - pTempContext = pContext; - pAdapter = pTempContext->pAdapter; - spin_lock(&hdd_context_lock); - if ((NULL == pAdapter) || (TEMP_CONTEXT_MAGIC != pTempContext->magic)) { - spin_unlock(&hdd_context_lock); - hdd_warn("Invalid context, pAdapter [%pK] magic [%08x]", - pAdapter, pTempContext->magic); + + request = hdd_request_get(context); + if (!request) { + hdd_err("Obsolete request"); return; } - if (temperature != 0) - pAdapter->temperature = temperature; - complete(&pTempContext->completion); - spin_unlock(&hdd_context_lock); + priv = hdd_request_priv(request); + priv->temperature = temperature; + hdd_request_complete(request); + hdd_request_put(request); + EXIT(); } @@ -7252,35 +7250,54 @@ static void hdd_get_temperature_cb(int temperature, void *pContext) * returned, otherwise a negative errno is returned. * */ -int wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, int *temperature) +int wlan_hdd_get_temperature(hdd_adapter_t *p_adapter, int *temperature) { QDF_STATUS status; - static struct statsContext tempContext; - unsigned long rc; + int ret; + void *cookie; + struct hdd_request *request; + struct temperature_priv *priv; + static const struct hdd_request_params params = { + .priv_size = sizeof(*priv), + .timeout_ms = WLAN_WAIT_TIME_STATS, + }; ENTER(); - if (NULL == pAdapter) { + if (!p_adapter) { hdd_err("pAdapter is NULL"); return -EPERM; } - init_completion(&tempContext.completion); - tempContext.pAdapter = pAdapter; - tempContext.magic = TEMP_CONTEXT_MAGIC; - status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(pAdapter), - &tempContext, hdd_get_temperature_cb); + + request = hdd_request_alloc(¶ms); + if (!request) { + hdd_err("Request allocation failure"); + return -ENOMEM; + } + cookie = hdd_request_cookie(request); + status = sme_get_temperature(WLAN_HDD_GET_HAL_CTX(p_adapter), + cookie, hdd_get_temperature_cb); if (QDF_STATUS_SUCCESS != status) { hdd_err("Unable to retrieve temperature"); } else { - rc = wait_for_completion_timeout(&tempContext.completion, - msecs_to_jiffies - (WLAN_WAIT_TIME_STATS)); - if (!rc) + ret = hdd_request_wait_for_response(request); + if (ret) { hdd_err("SME timed out while retrieving temperature"); + } else { + /* update the adapter with the fresh results */ + priv = hdd_request_priv(request); + if (priv->temperature) + p_adapter->temperature = priv->temperature; + } } - spin_lock(&hdd_context_lock); - tempContext.magic = 0; - spin_unlock(&hdd_context_lock); - *temperature = pAdapter->temperature; + + /* + * either we never sent a request, we sent a request and + * received a response or we sent a request and timed out. + * regardless we are done with the request. + */ + hdd_request_put(request); + + *temperature = p_adapter->temperature; EXIT(); return 0; } |
