Browse Source

qcacld-3.0: Refactor WE_SET_TX_POWER processing

Currently the HDD function with the highest cyclomatic complexity is
__iw_setint_getnone(). The handing of WE_SET_TX_POWER 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: I91f5da1593d5c8c6bfacbcc76e8595b3957b3ec2
CRs-Fixed: 2336981
Jeff Johnson 6 years ago
parent
commit
5d4a6d15ed
1 changed files with 23 additions and 21 deletions
  1. 23 21
      core/hdd/src/wlan_hdd_wext.c

+ 23 - 21
core/hdd/src/wlan_hdd_wext.c

@@ -4219,6 +4219,26 @@ static int hdd_we_set_wow_data_inactivity_timeout(struct hdd_adapter *adapter,
 	return qdf_status_to_os_return(status);
 }
 
+static int hdd_we_set_tx_power(struct hdd_adapter *adapter, int value)
+{
+	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+	mac_handle_t mac_handle = hdd_ctx->mac_handle;
+	QDF_STATUS status;
+
+	if (!mac_handle)
+		return -EINVAL;
+
+	status = sme_set_tx_power(mac_handle, adapter->session_id,
+				  sta_ctx->conn_info.bssId,
+				  adapter->device_mode, value);
+
+	if (QDF_IS_STATUS_ERROR(status))
+		hdd_err("cfg set failed, value %d status %d", value, 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
@@ -4277,31 +4297,13 @@ static int __iw_setint_getnone(struct net_device *dev,
 		break;
 
 	case WE_SET_MC_RATE:
-	{
-		if (!mac_handle)
-			return -EINVAL;
-
 		ret = wlan_hdd_set_mc_rate(adapter, set_value);
 		break;
-	}
-	case WE_SET_TX_POWER:
-	{
-		struct qdf_mac_addr bssid;
 
-		if (!mac_handle)
-			return -EINVAL;
-
-		qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId);
-		if (sme_set_tx_power
-			    (mac_handle, adapter->session_id, bssid,
-			    adapter->device_mode,
-			    set_value) != QDF_STATUS_SUCCESS) {
-			hdd_err("Setting tx power failed");
-			ret = -EIO;
-			break;
-		}
+	case WE_SET_TX_POWER:
+		ret = hdd_we_set_tx_power(adapter, set_value);
 		break;
-	}
+
 	case WE_SET_MAX_TX_POWER:
 	{
 		struct qdf_mac_addr bssid;