From 693722c4b4a391d62e5eb9f8cccd6099225dab65 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Fri, 19 Oct 2018 13:11:16 -0700 Subject: [PATCH] qcacld-3.0: Refactor WE_SET_DATA_INACTIVITY_TO processing Currently the HDD function with the highest cyclomatic complexity is __iw_setint_getnone(). The handing of WE_SET_DATA_INACTIVITY_TO has a complexity greater than 1, so refactor that logic into a separate function to help reduce the complexity of __iw_setint_getnone(). Change-Id: Ica3c1c31ac8ae88d02d5d34d2fc1e53aa70508b9 CRs-Fixed: 2336979 --- core/hdd/src/wlan_hdd_wext.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index e025e34d080a..4d8a261ba4c9 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -4172,6 +4172,27 @@ static int hdd_we_set_max_assoc(struct hdd_adapter *adapter, int value) return qdf_status_to_os_return(status); } +static int hdd_we_set_data_inactivity_timeout(struct hdd_adapter *adapter, + int value) +{ + struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); + mac_handle_t mac_handle = hdd_ctx->mac_handle; + tpAniSirGlobal mac_ctx; + + if (!mac_handle) + return -EINVAL; + + if (!cfg_in_range(CFG_PS_DATA_INACTIVITY_TIMEOUT, value)) { + hdd_err_rl("Invalid value %d", value); + return -EINVAL; + } + + mac_ctx = PMAC_STRUCT(mac_handle); + mac_ctx->mlme_cfg->timeouts.ps_data_inactivity_timeout = value; + + return 0; +} + /** * iw_setint_getnone() - Generic "set integer" private ioctl handler * @dev: device upon which the ioctl was received @@ -4221,19 +4242,9 @@ static int __iw_setint_getnone(struct net_device *dev, break; case WE_SET_DATA_INACTIVITY_TO: - if (!mac_handle) - return -EINVAL; - - if (cfg_in_range(CFG_PS_DATA_INACTIVITY_TIMEOUT, set_value)) { - tpAniSirGlobal mac_ctx = PMAC_STRUCT(mac_handle); - - mac_ctx->mlme_cfg->timeouts.ps_data_inactivity_timeout = - set_value; - } else { - hdd_err("Invalid inactivity timeout %d", set_value); - ret = -EINVAL; - } + ret = hdd_we_set_data_inactivity_timeout(adapter, set_value); break; + case WE_SET_WOW_DATA_INACTIVITY_TO: if (!mac_handle) { ret = -EINVAL;