diff mbox

[3/5] P2P: modify p2p_get_pref_freq

Message ID 1400483139-10247-4-git-send-email-ilan.peer@intel.com
State Superseded
Headers show

Commit Message

Peer, Ilan May 19, 2014, 7:05 a.m. UTC
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@intel.com>
---
 src/p2p/p2p_utils.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Jouni Malinen May 22, 2014, 9:51 p.m. UTC | #1
On Mon, May 19, 2014 at 10:05:37AM +0300, Ilan Peer wrote:
> 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.

> diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c
> index de47c12..8f1d4f6 100644

What is the base version used for this patch?

> @@ -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;
> -	}

This deleted section exist in hostap.git master branch..
Peer, Ilan May 23, 2014, 5:41 p.m. UTC | #2
> -----Original Message-----
> From: Jouni Malinen [mailto:j@w1.fi]
> Sent: Friday, May 23, 2014 00:52
> To: Peer, Ilan
> Cc: hostap@lists.shmoo.com
> Subject: Re: [PATCH 3/5] P2P: modify p2p_get_pref_freq
> 
> On Mon, May 19, 2014 at 10:05:37AM +0300, Ilan Peer wrote:
> > 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.
> 
> > diff --git a/src/p2p/p2p_utils.c b/src/p2p/p2p_utils.c index
> > de47c12..8f1d4f6 100644
> 
> What is the base version used for this patch?

Based on http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=commit;h=28fa4eb2b2dd971321e49591aade07d56695cf3e

This was before your patch " P2P: Iterate through full pref_chan list in search of a valid channel".

> 
> > @@ -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;
> > -	}
> 
> This deleted section exist in hostap.git master branch..
> 

Will send a fixed version.

Thanks in advance,

Ilan.
diff mbox

Patch

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;
 	}