All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 2/2] policy: Use btd_service_is_initiator
Date: Thu, 16 Sep 2021 13:40:20 -0700	[thread overview]
Message-ID: <20210916204020.118310-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20210916204020.118310-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Instead of using BTD_SERVICE_STATE_CONNECTING use
btd_service_is_initiator to determine if the service initiated the
connection and then proceed to connect other service immediately.

Fixes: https://github.com/bluez/bluez/issues/205
---
 plugins/policy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/policy.c b/plugins/policy.c
index bf93df096..051db82e1 100644
--- a/plugins/policy.c
+++ b/plugins/policy.c
@@ -279,7 +279,7 @@ static void sink_cb(struct btd_service *service, btd_service_state_t old_state,
 		/* Check if service initiate the connection then proceed
 		 * immediatelly otherwise set timer
 		 */
-		if (old_state == BTD_SERVICE_STATE_CONNECTING)
+		if (btd_service_is_initiator(service))
 			policy_connect(data, controller);
 		else if (btd_service_get_state(controller) !=
 						BTD_SERVICE_STATE_CONNECTED)
@@ -315,7 +315,7 @@ static void hs_cb(struct btd_service *service, btd_service_state_t old_state,
 		/* Check if service initiate the connection then proceed
 		 * immediately otherwise set timer
 		 */
-		if (old_state == BTD_SERVICE_STATE_CONNECTING)
+		if (btd_service_is_initiator(service))
 			policy_connect(data, sink);
 		else if (btd_service_get_state(sink) !=
 						BTD_SERVICE_STATE_CONNECTED)
@@ -430,7 +430,7 @@ static void source_cb(struct btd_service *service,
 		/* Check if service initiate the connection then proceed
 		 * immediatelly otherwise set timer
 		 */
-		if (old_state == BTD_SERVICE_STATE_CONNECTING)
+		if (btd_service_is_initiator(service))
 			policy_connect(data, target);
 		else if (btd_service_get_state(target) !=
 						BTD_SERVICE_STATE_CONNECTED)
-- 
2.31.1


  reply	other threads:[~2021-09-16 20:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 20:40 [PATCH v2 1/2] service: Add btd_service_is_initiator Luiz Augusto von Dentz
2021-09-16 20:40 ` Luiz Augusto von Dentz [this message]
2021-09-16 21:34 ` [v2,1/2] " bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916204020.118310-2-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.