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
This commit is contained in:
Jeff Johnson
2018-10-19 13:11:16 -07:00
committed by nshrivas
parent eb4368a044
commit 693722c4b4

View File

@@ -4172,6 +4172,27 @@ static int hdd_we_set_max_assoc(struct hdd_adapter *adapter, int value)
return qdf_status_to_os_return(status); 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 * iw_setint_getnone() - Generic "set integer" private ioctl handler
* @dev: device upon which the ioctl was received * @dev: device upon which the ioctl was received
@@ -4221,19 +4242,9 @@ static int __iw_setint_getnone(struct net_device *dev,
break; break;
case WE_SET_DATA_INACTIVITY_TO: case WE_SET_DATA_INACTIVITY_TO:
if (!mac_handle) ret = hdd_we_set_data_inactivity_timeout(adapter, set_value);
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;
}
break; break;
case WE_SET_WOW_DATA_INACTIVITY_TO: case WE_SET_WOW_DATA_INACTIVITY_TO:
if (!mac_handle) { if (!mac_handle) {
ret = -EINVAL; ret = -EINVAL;