From 7acca0dd656359549871bc3f9c652f97cc3c7885 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Fri, 16 Nov 2018 11:53:18 -0800 Subject: [PATCH] qcacld-3.0: Refactor GTX configuration One of the HDD functions with the highest cyclomatic complexity is __wlan_hdd_cfg80211_wifi_configuration_set(). In order to reduce the complexity there is a plan to replace the inline attribute handling with a vtable-based approach. As part of that goal refactor the following independent attribute handling into a separate function and add that function to the vtable: - QCA_WLAN_VENDOR_ATTR_CONFIG_GTX Change-Id: Ie64612653b55a3c75d035612d7a4a06cf5a1e772 CRs-Fixed: 2371588 --- core/hdd/src/wlan_hdd_cfg80211.c | 38 +++++++++++++++++++------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 7269e0d166a68..efa2053b577b5 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -6199,6 +6199,27 @@ static int hdd_config_rsn_ie(struct hdd_adapter *adapter, return 0; } +static int hdd_config_gtx(struct hdd_adapter *adapter, + const struct nlattr *attr) +{ + uint8_t config_gtx; + int errno; + + config_gtx = nla_get_u8(attr); + if (config_gtx > 1) { + hdd_err_rl("Invalid config_gtx value %d", config_gtx); + return -EINVAL; + } + + errno = sme_cli_set_command(adapter->session_id, + WMI_VDEV_PARAM_GTX_ENABLE, + config_gtx, VDEV_CMD); + if (errno) + hdd_err("Failed to set GTX, %d", errno); + + return errno; +} + /** * typedef independent_setter_fn - independent attribute handler * @adapter: The adapter being configured @@ -6281,6 +6302,8 @@ static const struct independent_setters independent_setters[] = { hdd_config_disable_fils}, {QCA_WLAN_VENDOR_ATTR_CONFIG_RSN_IE, hdd_config_rsn_ie}, + {QCA_WLAN_VENDOR_ATTR_CONFIG_GTX, + hdd_config_gtx}, }; /** @@ -6576,21 +6599,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, if (ret_val != 0) return ret_val; - if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GTX]) { - uint8_t config_gtx; - - config_gtx = nla_get_u8(tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GTX]); - if (config_gtx > 1) { - hdd_err_rl("Invalid config_gtx value %d", config_gtx); - return -EINVAL; - } - ret_val = sme_cli_set_command(adapter->session_id, - WMI_VDEV_PARAM_GTX_ENABLE, - config_gtx, VDEV_CMD); - if (ret_val) - hdd_err("Failed to set GTX"); - } - if (ret_val) errno = ret_val;