qcacld-3.0: Check TDLS offchannel is supported or not

Check if the configured tdls offchannel through IOCTL
is supported or not. This is required if firmware
does not support 5G channels or any invalid channels

Change-Id: I49e3b7b758fddf22fbfe1b64dda2e4f47a27cf3b
CRs-Fixed: 2503913
diff --git a/core/hdd/src/wlan_hdd_ioctl.c b/core/hdd/src/wlan_hdd_ioctl.c
index 41a3d80..67d770d 100644
--- a/core/hdd/src/wlan_hdd_ioctl.c
+++ b/core/hdd/src/wlan_hdd_ioctl.c
@@ -6089,24 +6089,28 @@
 {
 	int ret;
 	uint8_t *value = command;
-	int set_value;
+	int channel;
+	enum channel_state reg_state;
 
 	/* Move pointer to point the string */
 	value += command_len;
 
-	ret = sscanf(value, "%d", &set_value);
+	ret = sscanf(value, "%d", &channel);
 	if (ret != 1)
 		return -EINVAL;
+	reg_state = wlan_reg_get_channel_state(hdd_ctx->pdev, channel);
 
-	if (wlan_reg_is_dfs_ch(hdd_ctx->pdev, set_value)) {
-		hdd_err("DFS channel %d is passed for hdd_set_tdls_offchannel",
-		    set_value);
+	if (reg_state == CHANNEL_STATE_DFS ||
+		reg_state == CHANNEL_STATE_DISABLE ||
+		reg_state == CHANNEL_STATE_INVALID) {
+		hdd_err("reg state of the  channel %d is %d and not supported",
+			channel, reg_state);
 		return -EINVAL;
 	}
 
-	hdd_debug("Tdls offchannel num: %d", set_value);
+	hdd_debug("Tdls offchannel num: %d", channel);
 
-	ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, set_value);
+	ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, channel);
 
 	return ret;
 }