From 5e15ef5157bdcc5cc748e88c4ee685ffad6d8dbc Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Fri, 19 Oct 2018 15:29:56 -0700 Subject: [PATCH] qcacld-3.0: Refactor WE_SET_MAX_TX_POWER processing Currently the HDD function with the highest cyclomatic complexity is __iw_setint_getnone(). The handing of WE_SET_MAX_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: I9d2390aba4d90f7171de516be68f7073d1f2e4eb CRs-Fixed: 2336982 --- core/hdd/src/wlan_hdd_wext.c | 44 +++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 644e8e23a221..7f9fdd95e421 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -4239,6 +4239,27 @@ static int hdd_we_set_tx_power(struct hdd_adapter *adapter, int value) return qdf_status_to_os_return(status); } +static int hdd_we_set_max_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_max_tx_power(mac_handle, + sta_ctx->conn_info.bssId, + sta_ctx->conn_info.bssId, + 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 @@ -4254,7 +4275,6 @@ static int __iw_setint_getnone(struct net_device *dev, { struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); mac_handle_t mac_handle; - struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); struct hdd_context *hdd_ctx; int *value = (int *)extra; int sub_cmd = value[0]; @@ -4305,27 +4325,9 @@ static int __iw_setint_getnone(struct net_device *dev, break; case WE_SET_MAX_TX_POWER: - { - struct qdf_mac_addr bssid; - struct qdf_mac_addr selfMac; - - if (!mac_handle) - return -EINVAL; - - hdd_debug("Setting maximum tx power %d dBm", - set_value); - qdf_copy_macaddr(&bssid, &sta_ctx->conn_info.bssId); - qdf_copy_macaddr(&selfMac, &sta_ctx->conn_info.bssId); - - if (sme_set_max_tx_power(mac_handle, bssid, selfMac, set_value) - != QDF_STATUS_SUCCESS) { - hdd_err("Setting maximum tx power failed"); - ret = -EIO; - break; - } - + ret = hdd_we_set_max_tx_power(adapter, set_value); break; - } + case WE_SET_MAX_TX_POWER_2_4: { hdd_debug("Setting maximum tx power %d dBm for 2.4 GHz band",