From f15ede01fa8c2fa8a9291dcdff98ebbf8d8f7a4b Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Wed, 14 Nov 2018 13:27:13 -0800 Subject: [PATCH] qcacld-3.0: Refactor STATS_AVG_FACTOR 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_STATS_AVG_FACTOR Change-Id: Ife9ca5b48a3b64b3de674873a2faf2926df4e60a CRs-Fixed: 2371566 --- core/hdd/src/wlan_hdd_cfg80211.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 68b3f2d42572..82ebc26745c8 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -5688,6 +5688,21 @@ static int hdd_config_qpower(struct hdd_adapter *adapter, return hdd_set_qpower_config(hdd_ctx, adapter, qpower); } +static int hdd_config_stats_avg_factor(struct hdd_adapter *adapter, + const struct nlattr *attr) +{ + struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); + uint16_t stats_avg_factor; + QDF_STATUS status; + + stats_avg_factor = nla_get_u16(attr); + status = sme_configure_stats_avg_factor(hdd_ctx->mac_handle, + adapter->session_id, + stats_avg_factor); + + return qdf_status_to_os_return(status); +} + static int hdd_config_scan_default_ies(struct hdd_adapter *adapter, const struct nlattr *attr) { @@ -5775,6 +5790,8 @@ static const struct independent_setters independent_setters[] = { hdd_config_scan_enable}, {QCA_WLAN_VENDOR_ATTR_CONFIG_QPOWER, hdd_config_qpower}, + {QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR, + hdd_config_stats_avg_factor}, }; /** @@ -5888,7 +5905,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, int errno; int ret; int ret_val = 0; - u16 stats_avg_factor; u32 guard_time; uint8_t set_value; QDF_STATUS status; @@ -5942,17 +5958,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy, mac_handle = hdd_ctx->mac_handle; - if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]) { - stats_avg_factor = nla_get_u16( - tb[QCA_WLAN_VENDOR_ATTR_CONFIG_STATS_AVG_FACTOR]); - status = sme_configure_stats_avg_factor(mac_handle, - adapter->session_id, - stats_avg_factor); - - if (QDF_STATUS_SUCCESS != status) - ret_val = -EPERM; - } - if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]) { guard_time = nla_get_u32( tb[QCA_WLAN_VENDOR_ATTR_CONFIG_GUARD_TIME]);