From b43ec12eb5925f4c2a3aa8771f3b5265c055b83f Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Tue, 13 Nov 2018 14:17:08 -0800 Subject: [PATCH] qcacld-3.0: Refactor WE_SET_MODULATED_DTIM ioctl processing One of the HDD functions with the highest cyclomatic complexity is __iw_setint_getnone(). In order to reduce the complexity there is a plan to replace the existing switch with a vtable. As part of that goal refactor the WE_SET_MODULATED_DTIM ioctl handling into a separate function. Change-Id: I81701e1c54e62deb01468bb16a940ae823014d04 CRs-Fixed: 2350072 --- core/hdd/src/wlan_hdd_wext.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/core/hdd/src/wlan_hdd_wext.c b/core/hdd/src/wlan_hdd_wext.c index 1c1e1398bbe5..655403e4b12c 100644 --- a/core/hdd/src/wlan_hdd_wext.c +++ b/core/hdd/src/wlan_hdd_wext.c @@ -5139,6 +5139,26 @@ static int hdd_we_set_11ax_rate(struct hdd_adapter *adapter, int rate) return hdd_set_11ax_rate(adapter, rate, NULL); } +static int hdd_we_set_modulated_dtim(struct hdd_adapter *adapter, int value) +{ + struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); + + hdd_debug("%d", value); + + if (!hdd_ctx->psoc) + return -EINVAL; + + if ((value < cfg_max(CFG_PMO_ENABLE_MODULATED_DTIM)) || + (value > cfg_max(CFG_PMO_ENABLE_MODULATED_DTIM))) { + hdd_err("Invalid value %d", value); + return -EINVAL; + } + + ucfg_policy_mgr_set_sys_pref(hdd_ctx->psoc, value); + + return 0; +} + /** * iw_setint_getnone() - Generic "set integer" private ioctl handler * @dev: device upon which the ioctl was received @@ -5525,16 +5545,11 @@ static int __iw_setint_getnone(struct net_device *dev, case WE_SET_PDEV_RESET: ret = hdd_handle_pdev_reset(adapter, set_value); break; - case WE_SET_MODULATED_DTIM: - if ((set_value < cfg_max(CFG_PMO_ENABLE_MODULATED_DTIM)) || - (set_value > cfg_max(CFG_PMO_ENABLE_MODULATED_DTIM))) { - hdd_err("Invalid gEnableModuleDTIM value %d", - set_value); - return -EINVAL; - } - ucfg_pmo_set_sta_mod_dtim(hdd_ctx->psoc, set_value); + case WE_SET_MODULATED_DTIM: + ret = hdd_we_set_modulated_dtim(adapter, set_value); break; + default: hdd_debug("Invalid sub command %d", sub_cmd); ret = -EINVAL;