From patchwork Mon May 19 07:05:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peer, Ilan" X-Patchwork-Id: 350103 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 702F514008A for ; Mon, 19 May 2014 18:02:36 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id F0CFA9C158; Mon, 19 May 2014 04:02:28 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vlwn4jBU6Ugd; Mon, 19 May 2014 04:02:28 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 306E49C18A; Mon, 19 May 2014 04:02:10 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 8B9569C18A for ; Mon, 19 May 2014 04:02:08 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5rgaKqhllOKg for ; Mon, 19 May 2014 04:02:01 -0400 (EDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id B08C29C158 for ; Mon, 19 May 2014 04:02:01 -0400 (EDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 19 May 2014 00:56:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,865,1392192000"; d="scan'208";a="542674993" Received: from unknown (HELO ipeer-e6430-1.jer.intel.com) ([10.12.217.172]) by orsmga002.jf.intel.com with ESMTP; 19 May 2014 01:01:41 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH 3/5] P2P: modify p2p_get_pref_freq Date: Mon, 19 May 2014 10:05:37 +0300 Message-Id: <1400483139-10247-4-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1400483139-10247-1-git-send-email-ilan.peer@intel.com> References: <1400483139-10247-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 --- 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; }