[PATCH 3/5 v2] P2P: modify p2p_get_pref_freq

Ilan Peer ilan.peer
Fri May 23 10:03:01 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 |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
index 06cb646..d22d3a6 100644
--- a/src/p2p/p2p_utils.c
+++ b/src/p2p/p2p_utils.c
@@ -384,17 +384,19 @@ unsigned int p2p_get_pref_freq(struct p2p_data *p2p,
 			       const struct p2p_channels *channels)
 {
 	unsigned int i;
-	int freq;
+	int freq = 0;
+	struct p2p_channels *tmpc = channels ?
+		(struct p2p_channels *)channels : &p2p->cfg->channels;
+
+	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 (freq <= 0)
-			continue;
-		if (!channels || p2p_channels_includes_freq(channels, freq))
+		if (p2p_channels_includes_freq(tmpc, freq))
 			return freq;
 	}
-
 	return 0;
 }
 
-- 
1.7.10.4




More information about the Hostap mailing list