Browse Source

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
Jeff Johnson 6 years ago
parent
commit
693722c4b4
1 changed files with 23 additions and 12 deletions
  1. 23 12
      core/hdd/src/wlan_hdd_wext.c

+ 23 - 12
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;