From d90f61a13c1bb39ad51ea5b066f3a00e5f48588e Mon Sep 17 00:00:00 2001 From: Dustin Brown Date: Thu, 26 Apr 2018 12:25:58 -0700 Subject: [PATCH] qcacld-3.0: Extract WE_SET_11D_STATE handling Extract the sub-IOCTL handling for WE_SET_11D_STATE into its own function. Change-Id: I879ea977e23945aa7d85a6f9ebb3194d9761fd0c CRs-Fixed: 2232056 --- core/hdd/src/wlan_hdd_wext.c | 55 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index a4f91e91688f..50a2a0b114b8 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -4204,6 +4204,42 @@ free_config: return errno; } +static int hdd_we_set_11d_state(struct hdd_context *hdd_ctx, int state_11d) +{ + tSmeConfigParams *sme_config; + bool enable_11d; + + if (!hdd_ctx->hHal) + return -EINVAL; + + switch (state_11d) { + case ENABLE_11D: + enable_11d = true; + break; + case DISABLE_11D: + enable_11d = false; + break; + default: + return -EINVAL; + } + + sme_config = qdf_mem_malloc(sizeof(*sme_config)); + if (!sme_config) { + hdd_err("failed to allocate memory for sme_config"); + return -ENOMEM; + } + + sme_get_config_param(hdd_ctx->hHal, sme_config); + sme_config->csrConfig.Is11dSupportEnabled = enable_11d; + sme_update_config(hdd_ctx->hHal, sme_config); + + qdf_mem_free(sme_config); + + hdd_debug("11D state=%d", sme_config->csrConfig.Is11dSupportEnabled); + + return 0; +} + /** * iw_setint_getnone() - Generic "set integer" private ioctl handler * @dev: device upon which the ioctl was received @@ -4252,25 +4288,8 @@ static int __iw_setint_getnone(struct net_device *dev, switch (sub_cmd) { case WE_SET_11D_STATE: - { - if (((ENABLE_11D == set_value) - || (DISABLE_11D == set_value)) && hHal) { - - sme_get_config_param(hHal, sme_config); - sme_config->csrConfig.Is11dSupportEnabled = - (bool) set_value; - - hdd_debug("11D state=%d!!", - sme_config->csrConfig. - Is11dSupportEnabled); - - sme_update_config(hHal, sme_config); - } else { - ret = -EINVAL; - goto free; - } + ret = hdd_we_set_11d_state(hdd_ctx, set_value); break; - } case WE_SET_POWER: {