diff options
| author | gaolez <gaolez@codeaurora.org> | 2018-03-20 10:10:54 +0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-04-11 00:05:35 -0700 |
| commit | bc8085c2e2798e78dd306cec720b5eb7c709c860 (patch) | |
| tree | 540b1c7d6054688e236176643b0927384fa33d8d | |
| parent | 43d751c3600e6f6f377ec676bd54a6814eb90589 (diff) | |
qcacld-2.0: Use request manager for get temperature
propagation from qcacld-3.0 to qcacld-2.0
We are transitioning to the new request manager framework. Change
wlan_hdd_get_temperature() and hdd_GetTemperatureCB() to this
framework.
Change-Id: I3b828827acaa16a64a8a6cfd1c0665da7be166de
CRs-Fixed: 2207693
| -rw-r--r-- | CORE/HDD/inc/wlan_hdd_wext.h | 4 | ||||
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_wext.c | 166 |
2 files changed, 80 insertions, 90 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_wext.h b/CORE/HDD/inc/wlan_hdd_wext.h index bf8fe01114d5..4424a37b0e1e 100644 --- a/CORE/HDD/inc/wlan_hdd_wext.h +++ b/CORE/HDD/inc/wlan_hdd_wext.h @@ -478,7 +478,7 @@ int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal, int process_wma_set_command_twoargs(int sessid, int paramid, int sval, int ssecval, int vpdev); -void hdd_GetTemperatureCB(int temperature, void *pContext); -VOS_STATUS wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, +void hdd_GetTemperatureCB(int temperature, void *cookie); +VOS_STATUS wlan_hdd_get_temperature(hdd_adapter_t *adapter_ptr, union iwreq_data *wrqu, char *extra); #endif // __WEXT_IW_H__ diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c index 871cf3c5b052..ed1c8bd31b01 100644 --- a/CORE/HDD/src/wlan_hdd_wext.c +++ b/CORE/HDD/src/wlan_hdd_wext.c @@ -5770,111 +5770,101 @@ int wlan_hdd_update_phymode(struct net_device *net, tHalHandle hal, return 0; } -void hdd_GetTemperatureCB(int temperature, void *pContext) -{ - struct statsContext *pTempContext; - hdd_adapter_t *pAdapter; - - ENTER(); - - if (NULL == pContext) { - hddLog(VOS_TRACE_LEVEL_ERROR, FL("pContext is NULL")); - return; - } - - pTempContext = pContext; - pAdapter = pTempContext->pAdapter; +struct temperature_info { + int temperature; +}; - /* there is a race condition that exists between this callback - function and the caller since the caller could time out either - before or while this code is executing. we use a spinlock to - serialize these actions */ - spin_lock(&hdd_context_lock); +void hdd_GetTemperatureCB(int temperature, void *cookie) +{ + struct hdd_request *request; + struct temperature_info *priv; - if ((NULL == pAdapter) || - (TEMP_CONTEXT_MAGIC != pTempContext->magic)) - { - /* the caller presumably timed out so there is nothing we can do */ - spin_unlock(&hdd_context_lock); - hddLog(VOS_TRACE_LEVEL_WARN, - FL("Invalid context, pAdapter [%pK] magic [%08x]"), - pAdapter, pTempContext->magic); - return; - } + ENTER(); - /* context is valid, update the temperature, ignore it if this was 0 */ - if (temperature != 0) { - pAdapter->temperature = temperature; - } + request = hdd_request_get(cookie); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Obsolete request", __func__); + return; + } + priv = hdd_request_priv(request); - /* notify the caller */ - complete(&pTempContext->completion); + priv->temperature = temperature; - /* serialization is complete */ - spin_unlock(&hdd_context_lock); + hdd_request_complete(request); + hdd_request_put(request); - EXIT(); + EXIT(); } -VOS_STATUS wlan_hdd_get_temperature(hdd_adapter_t *pAdapter, +VOS_STATUS wlan_hdd_get_temperature(hdd_adapter_t *adapter_ptr, union iwreq_data *wrqu, char *extra) { - eHalStatus hstatus; - struct statsContext tempContext; - unsigned long rc; - A_INT32 *pData = (A_INT32 *)extra; - - ENTER(); + eHalStatus hstatus; + int ret; + A_INT32 *data_ptr = (A_INT32 *)extra; + void *cookie; + struct hdd_request *request; + struct temperature_info *priv; + static const struct hdd_request_params params = { + .priv_size = sizeof(*priv), + .timeout_ms = WLAN_WAIT_TIME_STATS, + }; - if (NULL == pAdapter) - { - hddLog(VOS_TRACE_LEVEL_ERROR, FL("pAdapter is NULL")); - return VOS_STATUS_E_FAULT; - } + ENTER(); - /* prepare callback context and magic pattern */ - init_completion(&tempContext.completion); - tempContext.pAdapter = pAdapter; - tempContext.magic = TEMP_CONTEXT_MAGIC; + if (NULL == adapter_ptr) + { + hddLog(VOS_TRACE_LEVEL_ERROR, + FL("pAdapter is NULL")); + return VOS_STATUS_E_FAULT; + } - /* send get temperature request to sme */ - hstatus = sme_GetTemperature( - WLAN_HDD_GET_HAL_CTX(pAdapter), - &tempContext, - hdd_GetTemperatureCB); + request = hdd_request_alloc(¶ms); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Request allocation failure", __func__); + return VOS_STATUS_E_NOMEM; + } + cookie = hdd_request_cookie(request); - if (eHAL_STATUS_SUCCESS != hstatus) { - hddLog(VOS_TRACE_LEVEL_ERROR, FL("Unable to retrieve temperature")); - } else { - /* request was sent -- wait for the response */ - rc = wait_for_completion_timeout(&tempContext.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_STATS)); - if (!rc) { - hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while retrieving temperature")); - } - } + /* send get temperature request to sme */ + hstatus = + sme_GetTemperature(WLAN_HDD_GET_HAL_CTX(adapter_ptr), + cookie, + hdd_GetTemperatureCB); - /* either we never sent a request, we sent a request and received a - response or we sent a request and timed out. if we never sent a - request or if we sent a request and got a response, we want to - clear the magic out of paranoia. if we timed out there is a - race condition such that the callback function could be - executing at the same time we are. of primary concern is if the - callback function had already verified the "magic" but had not - yet set the completion variable when a timeout occurred. we - serialize these activities by invalidating the magic while - holding a shared spinlock which will cause us to block if the - callback is currently executing */ - spin_lock(&hdd_context_lock); - tempContext.magic = 0; - spin_unlock(&hdd_context_lock); + if (eHAL_STATUS_SUCCESS != hstatus) { + hddLog(VOS_TRACE_LEVEL_ERROR, + FL("Unable to retrieve temperature")); + } else { + /* request was sent -- wait for the response */ + ret = hdd_request_wait_for_response(request); + if (ret) { + hddLog(VOS_TRACE_LEVEL_WARN, + FL("timeout when get temperature")); + /* we'll returned a cached value below */ + } else { + /* update the adapter with the fresh results */ + priv = hdd_request_priv(request); + /* ignore it if this was 0 */ + if (priv->temperature != 0) + adapter_ptr->temperature = + priv->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); - /* update temperature */ - *pData = pAdapter->temperature; + /* update temperature */ + *data_ptr = adapter_ptr->temperature; - EXIT(); - return VOS_STATUS_SUCCESS; + EXIT(); + return VOS_STATUS_SUCCESS; } /** |
