Browse Source

qcacld-3.0: Refactor WE_SET_MAX_TX_POWER_5_0 processing

Currently the HDD function with the highest cyclomatic complexity is
__iw_setint_getnone(). The handing of WE_SET_MAX_TX_POWER_5_0 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: I3eb942b5bbed7cdc8199c5a4233b4443613023b0
CRs-Fixed: 2338379
Jeff Johnson 6 years ago
parent
commit
175004cd2e
1 changed files with 13 additions and 11 deletions
  1. 13 11
      core/hdd/src/wlan_hdd_wext.c

+ 13 - 11
core/hdd/src/wlan_hdd_wext.c

@@ -4272,6 +4272,18 @@ static int hdd_we_set_max_tx_power_2_4(struct hdd_adapter *adapter, int power)
 	return qdf_status_to_os_return(status);
 }
 
+static int hdd_we_set_max_tx_power_5_0(struct hdd_adapter *adapter, int power)
+{
+	QDF_STATUS status;
+
+	hdd_debug("power %d dBm", power);
+	status = sme_set_max_tx_power_per_band(BAND_5G, power);
+	if (QDF_IS_STATUS_ERROR(status))
+		hdd_err("cfg set failed, value %d status %d", power, status);
+
+	return qdf_status_to_os_return(status);
+}
+
 /**
  * iw_setint_getnone() - Generic "set integer" private ioctl handler
  * @dev: device upon which the ioctl was received
@@ -4345,18 +4357,8 @@ static int __iw_setint_getnone(struct net_device *dev,
 		break;
 
 	case WE_SET_MAX_TX_POWER_5_0:
-	{
-		hdd_debug("Setting maximum tx power %d dBm for 5.0 GHz band",
-			   set_value);
-		if (sme_set_max_tx_power_per_band(BAND_5G, set_value) !=
-		    QDF_STATUS_SUCCESS) {
-			hdd_err("Setting max tx power failed for 5.0 GHz band");
-			ret = -EIO;
-			break;
-		}
-
+		ret = hdd_we_set_max_tx_power_5_0(adapter, set_value);
 		break;
-	}
 
 	case WE_SET_TM_LEVEL:
 	{