[PATCH 3/5] P2P: modify p2p_get_pref_freq

Ilan Peer ilan.peer
Mon May 19 00:05:37 PDT 2014


In p2p_get_pref_freq, if the channels argument is NULL,
select a preferred channel that is also one of the P2P Device
configured channels.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/p2p/p2p_utils.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index de47c12..8f1d4f6 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -385,22 +385,16 @@ unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
 {
 	unsigned int i;
 	int freq = 0;
+	struct p2p_channels *tmpc = channels ?
+		(struct p2p_channels *)channels : &p2p->cfg->channels;
 
-	if (channels == NULL) {
-		if (p2p->cfg->num_pref_chan) {
-			freq = p2p_channel_to_freq(
-				p2p->cfg->pref_chan[0].op_class,
-				p2p->cfg->pref_chan[0].chan);
-			if (freq < 0)
-				freq = 0;
-		}
-		return freq;
-	}
+	if (tmpc == NULL)
+		return 0;
 
 	for (i = 0; p2p->cfg->pref_chan && i < p2p->cfg->num_pref_chan; i++) {
 		freq = p2p_channel_to_freq(p2p->cfg->pref_chan[i].op_class,
 					   p2p->cfg->pref_chan[i].chan);
-		if (p2p_channels_includes_freq(channels, freq))
+		if (p2p_channels_includes_freq(tmpc, freq))
 			return freq;
 	}
 
-- 
1.7.10.4




More information about the Hostap mailing list