diff options
| author | wadesong <wadesong@codeaurora.org> | 2018-03-19 15:15:13 +0800 |
|---|---|---|
| committer | wadesong <wadesong@codeaurora.org> | 2018-03-23 10:14:01 +0800 |
| commit | 4aa30844e28eb4b410f86d97e970a39fcdfd797d (patch) | |
| tree | 9ac382d56cb0669163df88fcadf0b97fb682087f | |
| parent | d340bb85e1664db5d101ec5b0ed80ca6a1838eb2 (diff) | |
qcacld-2.0: Use request manager to handle WE_SET_POWER requests
Use the new request manager framework for handling WE_SET_POWER
related iw requests.
Change-Id: I1d833ced2096a92b855cc861c84a448029e592b7
CRs-Fixed: 2208402
| -rw-r--r-- | CORE/HDD/src/wlan_hdd_wext.c | 131 |
1 files changed, 70 insertions, 61 deletions
diff --git a/CORE/HDD/src/wlan_hdd_wext.c b/CORE/HDD/src/wlan_hdd_wext.c index eeeeab621601..17cccac61624 100644 --- a/CORE/HDD/src/wlan_hdd_wext.c +++ b/CORE/HDD/src/wlan_hdd_wext.c @@ -3640,6 +3640,27 @@ static int iw_get_range(struct net_device *dev, struct iw_request_info *info, } /** + * iw_power_callback_func() - Callback function registered with PMC + * @context: cookie originally registered with PMC + * @status: status code indicated by PMC state machine + * + * Return: None + */ +static void iw_power_callback_func(void *context, eHalStatus status) +{ + struct hdd_request *request = hdd_request_get(context); + + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Obsolete request", __func__); + return; + } + + hdd_request_complete(request); + hdd_request_put(request); +} + +/** * iw_power_offload_callback_fn() - Callback function registered with PMC to * know status of PMC request * @@ -6142,45 +6163,39 @@ static int __iw_setint_getnone(struct net_device *dev, { case 0: //Full Power { - struct statsContext context; + struct hdd_request *request; + void *cookie; + static const struct hdd_request_params params = { + .priv_size = 0, + .timeout_ms = WLAN_WAIT_TIME_POWER, + }; eHalStatus status = eHAL_STATUS_FAILURE; - init_completion(&context.completion); - - context.pAdapter = pAdapter; - context.magic = POWER_CONTEXT_MAGIC; - if (NULL == hHal) return -EINVAL; - status = sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter), - iw_power_callback_fn, &context, - eSME_FULL_PWR_NEEDED_BY_HDD); - if (eHAL_STATUS_PMC_PENDING == status) - { - unsigned long rc; - rc = wait_for_completion_timeout( - &context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); + request = hdd_request_alloc(¶ms); + if (!request) { + hddLog(VOS_TRACE_LEVEL_ERROR, + "%s: Request allocation failure", __func__); + return VOS_STATUS_E_NOMEM; + } - if (!rc) { + cookie = hdd_request_cookie(request); + status = sme_RequestFullPower(hHal, + iw_power_callback_func, cookie, + eSME_FULL_PWR_NEEDED_BY_HDD); + if (eHAL_STATUS_PMC_PENDING == status) { + if(hdd_request_wait_for_response(request)) hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while requesting full power")); - } + FL("SME timed out while requesting full power")); } - /* either we have a response or we timed out. 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); - context.magic = 0; - spin_unlock(&hdd_context_lock); - + /* + * 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); hddLog(LOGE, "iwpriv Full Power completed"); break; } @@ -6198,44 +6213,38 @@ static int __iw_setint_getnone(struct net_device *dev, break; case 3: //Request Bmps { - struct statsContext context; + struct hdd_request *request; + void *cookie; + static const struct hdd_request_params params = { + .priv_size = 0, + .timeout_ms = WLAN_WAIT_TIME_POWER, + }; eHalStatus status = eHAL_STATUS_FAILURE; - init_completion(&context.completion); - - context.pAdapter = pAdapter; - context.magic = POWER_CONTEXT_MAGIC; - if (NULL == hHal) return -EINVAL; + 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); status = sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), - iw_power_callback_fn, &context); - if (eHAL_STATUS_PMC_PENDING == status) - { - unsigned long rc; - rc = wait_for_completion_timeout( - &context.completion, - msecs_to_jiffies(WLAN_WAIT_TIME_POWER)); - if (!rc) { + iw_power_callback_func, cookie); + if (eHAL_STATUS_PMC_PENDING == status) { + if (hdd_request_wait_for_response(request)) hddLog(VOS_TRACE_LEVEL_ERROR, - FL("SME timed out while requesting BMPS")); - } + FL("SME timed out while requesting BMPS")); } - /* either we have a response or we timed out. 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); - context.magic = 0; - spin_unlock(&hdd_context_lock); - + /* + * 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); hddLog(LOGE, "iwpriv Request BMPS completed"); break; } |
