Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5749364ybl; Tue, 10 Dec 2019 10:52:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwzhvqW0IHDXclF2jBpX9sZIcxYiKs4HZ2uAufUVLCbkXp/izWptv6EXC9XiVKHX85Nhqqq X-Received: by 2002:a9d:578a:: with SMTP id q10mr23935905oth.215.1576003963784; Tue, 10 Dec 2019 10:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576003963; cv=none; d=google.com; s=arc-20160816; b=VFPsZVgJezVlxlukwL/CS9xWLER+H68RGq6CSHzaSFWqlPS5VO4tKpQVOx1KMhZB+L mSW1DAY9mwde1dNIfV5ggmPOepRK9N/miDVrhPvQp0Xv4oYL3l+MuWYYREtK7ZW5fUf9 9zc+Ouas5qyMwThbhhdQvkRmq/YcnkSA7MwzKEh2kKAYhXodQbtODE2YmflJyAMFBvNP Tq8t/n4fB9n2ED1CAXBsHi4UP82fkdsLj9GSTDbc+g1jqEqmha0+8GnQObLqWP7Pk1Hb fpGgUXsTdlfkI0PLaLCjYtwNYm9vId62PgIDJB+RD6I1sOajRAUTw7AZR3zCgyJaQ+Co H3KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=f4SNvdeuCUMM+J5B95kMpWBfOUx0LA04wLipvl/08/I=; b=D4UR425Y/cAwPntkGXwuwZnADyk4fW/9VSovqYQ+fiFiXc3tV0KJA1rt+aVYN9cWt9 6umviOvmt1h4KExGOqtAmDQjUjMe+z232ggCCdMJNr9s8hB2Bviht2u3t2Po+52ahaR1 q2k+VfVIRtABMM2CykrEh2vSY7mGfydcZT0zvJ0lm5j/WzwqSN3g8wqBmC9PKu0Pd93E RgGQv4j9drFfF3lDb04aMuVJ4JaRASy2A29Hz4PQWkjzTyzWl27xN0YAtm1jGFoSk4qS 0TRMlFdZFzjaaBO7h1E+T/7zl0qT99h+MPFjCd64kcqF7yHDKlc0qQo24Lvke4XNUt9x +MuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si2463431otb.49.2019.12.10.10.52.23; Tue, 10 Dec 2019 10:52:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727520AbfLJSwN (ORCPT + 99 others); Tue, 10 Dec 2019 13:52:13 -0500 Received: from mga11.intel.com ([192.55.52.93]:40134 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbfLJSwN (ORCPT ); Tue, 10 Dec 2019 13:52:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2019 10:52:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,300,1571727600"; d="scan'208";a="295981314" Received: from ingas-nuc1.sea.intel.com ([10.254.187.166]) by orsmga001.jf.intel.com with ESMTP; 10 Dec 2019 10:52:12 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Fix check for found hci controllers Date: Tue, 10 Dec 2019 10:52:10 -0800 Message-Id: <20191210185210.17403-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes the queue look up when checking for hci controllers. --- mesh/mesh-mgmt.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mesh/mesh-mgmt.c b/mesh/mesh-mgmt.c index 27272d4d2..a2881dc37 100644 --- a/mesh/mesh-mgmt.c +++ b/mesh/mesh-mgmt.c @@ -45,9 +45,18 @@ static struct mgmt *mgmt_mesh; static struct l_queue *controllers; static struct l_queue *read_info_regs; -static bool simple_match(const void *a, const void *b) +static bool index_present(uint16_t index) { - return a == b; + const struct l_queue_entry *l = l_queue_get_entries(controllers); + + for (; l; l = l->next) { + uint16_t idx = (uint16_t) L_PTR_TO_UINT(l->data); + + if (idx == index) + return true; + } + + return false; } static void process_read_info_req(void *data, void *user_data) @@ -101,7 +110,7 @@ static void read_info_cb(uint8_t status, uint16_t length, static void index_added(uint16_t index, uint16_t length, const void *param, void *user_data) { - if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index))) + if (index_present(index)) return; l_queue_push_tail(controllers, L_UINT_TO_PTR(index)); -- 2.21.0