Browse Source

qcacld-3.0: Add helper function cds_combine_channel_states

cds_combine_channel_states to select final channel state based
on the two channel states specially when operating on 80+80 MHZ.

Change-Id: I5f470c96ce499c8d9aa2e41ceff59cdfc2f31151
CRs-Fixed: 1075098
Arif Hussain 8 years ago
parent
commit
d944578076
1 changed files with 24 additions and 3 deletions
  1. 24 3
      core/cds/src/cds_reg_service.c

+ 24 - 3
core/cds/src/cds_reg_service.c

@@ -436,6 +436,23 @@ enum channel_state cds_get_5g_bonded_channel_state(
 		return CHANNEL_STATE_DISABLE;
 }
 
+/**
+ * cds_combine_channel_states() - combine channel states
+ * @chan_state1: channel state1
+ * @chan_state2: channel state2
+ *
+ * Return: enum channel_state
+ */
+ static enum channel_state cds_combine_channel_states(
+		 enum channel_state chan_state1,
+		 enum channel_state chan_state2)
+{
+	if ((CHANNEL_STATE_INVALID == chan_state1) ||
+	    (CHANNEL_STATE_INVALID == chan_state2))
+		return CHANNEL_STATE_INVALID;
+	else
+		return min(chan_state1, chan_state2);
+}
 
 /**
  * cds_set_5g_channel_params() - set the 5G bonded channel parameters
@@ -456,6 +473,8 @@ static void cds_set_5g_channel_params(uint16_t oper_ch,
 		ch_params->ch_width = CH_WIDTH_80P80MHZ;
 
 	while (ch_params->ch_width != CH_WIDTH_INVALID) {
+		bonded_chan_ptr = NULL;
+		bonded_chan_ptr2 = NULL;
 		chan_state = cds_search_5g_bonded_channel(oper_ch,
 							  ch_params->ch_width,
 							  &bonded_chan_ptr);
@@ -468,14 +487,16 @@ static void cds_set_5g_channel_params(uint16_t oper_ch,
 				ch_params->center_freq_seg1 - 2,
 				CH_WIDTH_80MHZ);
 
-		if (chan_state2 < chan_state)
-			chan_state = chan_state2;
+		chan_state = cds_combine_channel_states(chan_state,
+							chan_state2);
+
 		if ((CHANNEL_STATE_ENABLE == chan_state) ||
 		    (CHANNEL_STATE_DFS == chan_state)) {
 			if (CH_WIDTH_20MHZ >= ch_params->ch_width) {
 				ch_params->sec_ch_offset
 					= PHY_SINGLE_CHANNEL_CENTERED;
 				ch_params->center_freq_seg0 = oper_ch;
+				break;
 			} else if (CH_WIDTH_40MHZ <= ch_params->ch_width) {
 				cds_search_5g_bonded_chan_array(oper_ch,
 							bonded_chan_40mhz_array,
@@ -493,9 +514,9 @@ static void cds_set_5g_channel_params(uint16_t oper_ch,
 					ch_params->center_freq_seg0 =
 						(bonded_chan_ptr->start_ch +
 						 bonded_chan_ptr->end_ch)/2;
+					break;
 				}
 			}
-			break;
 		}
 		ch_params->ch_width = next_lower_bw[ch_params->ch_width];
 	}