Explorar el Código

qcacld-3.0: Refactor WE_SET_VHT_RATE processing

One of the HDD functions with the highest cyclomatic complexity is
__iw_setint_getnone(). The handing of WE_SET_VHT_RATE 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: I07299bcc7e1cba7b5ceced3ba1cf22c470cb448e
CRs-Fixed: 2340146
Jeff Johnson hace 6 años
padre
commit
bd2c9916ae
Se han modificado 1 ficheros con 27 adiciones y 16 borrados
  1. 27 16
      core/hdd/src/wlan_hdd_wext.c

+ 27 - 16
core/hdd/src/wlan_hdd_wext.c

@@ -4419,6 +4419,32 @@ static int hdd_we_set_11n_rate(struct hdd_adapter *adapter, int rate_code)
 	return errno;
 }
 
+static int hdd_we_set_vht_rate(struct hdd_adapter *adapter, int rate_code)
+{
+	uint8_t preamble = 0, nss = 0, rix = 0;
+	int errno;
+
+	hdd_debug("Rate code %d", rate_code);
+
+	if (rate_code != 0xff) {
+		rix = RC_2_RATE_IDX_11AC(rate_code);
+		preamble = WMI_RATE_PREAMBLE_VHT;
+		nss = HT_RC_2_STREAMS_11AC(rate_code) - 1;
+		rate_code = hdd_assemble_rate_code(preamble, nss, rix);
+	}
+
+	hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
+		  rate_code, rix, preamble, nss);
+
+	errno = wma_cli_set_command(adapter->session_id,
+				    WMI_VDEV_PARAM_FIXED_RATE,
+				    rate_code, VDEV_CMD);
+	if (errno)
+		hdd_err("Failed to set firmware, errno %d", errno);
+
+	return errno;
+}
+
 /**
  * iw_setint_getnone() - Generic "set integer" private ioctl handler
  * @dev: device upon which the ioctl was received
@@ -4679,23 +4705,8 @@ static int __iw_setint_getnone(struct net_device *dev,
 		break;
 
 	case WE_SET_VHT_RATE:
-	{
-		uint8_t preamble = 0, nss = 0, rix = 0;
-
-		if (set_value != 0xff) {
-			rix = RC_2_RATE_IDX_11AC(set_value);
-			preamble = WMI_RATE_PREAMBLE_VHT;
-			nss = HT_RC_2_STREAMS_11AC(set_value) - 1;
-
-			set_value = hdd_assemble_rate_code(preamble, nss, rix);
-		}
-		hdd_debug("WMI_VDEV_PARAM_FIXED_RATE val %d rix %d preamble %x nss %d",
-			 set_value, rix, preamble, nss);
-		ret = wma_cli_set_command(adapter->session_id,
-					  WMI_VDEV_PARAM_FIXED_RATE,
-					  set_value, VDEV_CMD);
+		ret = hdd_we_set_vht_rate(adapter, set_value);
 		break;
-	}
 
 	case WE_SET_AMPDU:
 	{