Ver código fonte

qcacld-3.0: Refactor RESTRICT_OFFCHANNEL 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_RESTRICT_OFFCHANNEL

Change-Id: I34d7a8a3526a80f5cdbe2bab4a663a0f41b6a4d7
CRs-Fixed: 2371580
Jeff Johnson 6 anos atrás
pai
commit
72dc91e518
1 arquivos alterados com 19 adições e 15 exclusões
  1. 19 15
      core/hdd/src/wlan_hdd_cfg80211.c

+ 19 - 15
core/hdd/src/wlan_hdd_cfg80211.c

@@ -5993,6 +5993,23 @@ static int hdd_config_ignore_assoc_disallowed(struct hdd_adapter *adapter,
 	return 0;
 }
 
+static int hdd_config_restrict_offchannel(struct hdd_adapter *adapter,
+					  const struct nlattr *attr)
+{
+	uint8_t restrict_offchan;
+
+	restrict_offchan = nla_get_u8(attr);
+	hdd_debug("%u", restrict_offchan);
+
+	if (restrict_offchan > 1) {
+		hdd_err("Invalid value %u", restrict_offchan);
+		return -EINVAL;
+	}
+
+	return wlan_hdd_handle_restrict_offchan_config(adapter,
+						       restrict_offchan);
+}
+
 /**
  * typedef independent_setter_fn - independent attribute handler
  * @adapter: The adapter being configured
@@ -6059,6 +6076,8 @@ static const struct independent_setters independent_setters[] = {
 	 hdd_config_ant_div_probe_dwell_time},
 	{QCA_WLAN_VENDOR_ATTR_CONFIG_IGNORE_ASSOC_DISALLOWED,
 	 hdd_config_ignore_assoc_disallowed},
+	{QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL,
+	 hdd_config_restrict_offchannel},
 };
 
 /**
@@ -6351,21 +6370,6 @@ __wlan_hdd_cfg80211_wifi_configuration_set(struct wiphy *wiphy,
 		}
 	}
 
-	if (tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL]) {
-		u8 restrict_offchan = nla_get_u8(
-			tb[QCA_WLAN_VENDOR_ATTR_CONFIG_RESTRICT_OFFCHANNEL]);
-
-		hdd_debug("Restrict offchannel:%d", restrict_offchan);
-		if (restrict_offchan <= 1)
-			ret_val =
-			wlan_hdd_handle_restrict_offchan_config(adapter,
-							restrict_offchan);
-		else {
-			ret_val = -EINVAL;
-			hdd_err("Invalid RESTRICT_OFFCHAN setting");
-		}
-	}
-
 	ret_val =
 		wlan_hdd_cfg80211_wifi_set_reorder_timeout(hdd_ctx, tb);
 	if (ret_val != 0)