linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@gmail.com>
Subject: [PATCH 2/5] android/gatt: Factor out unregistering client into helper function
Date: Mon, 26 May 2014 23:53:25 +0200	[thread overview]
Message-ID: <1401141208-26912-3-git-send-email-szymon.janc@gmail.com> (raw)
In-Reply-To: <1401141208-26912-1-git-send-email-szymon.janc@gmail.com>

This will be also used by test interface.
---
 android/gatt.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 0acb4b6..8b0082e 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1360,28 +1360,35 @@ static bool trigger_connection(struct app_connection *connection)
 	return true;
 }
 
+static uint8_t unregister_client(int client_if)
+{
+	struct gatt_app *cl;
+
+	cl = queue_remove_if(gatt_apps, match_app_by_id, INT_TO_PTR(client_if));
+	if (!cl) {
+		error("gatt: client_if=%d not found", client_if);
+
+		return HAL_STATUS_FAILED;
+	}
+
+	/*
+	 * Check if there is any connect request or connected device
+	 * for this client. If so, remove this client from those lists.
+	 */
+	app_disconnect_devices(cl);
+	destroy_gatt_app(cl);
+
+	return HAL_STATUS_SUCCESS;
+}
+
 static void handle_client_unregister(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_unregister *cmd = buf;
 	uint8_t status;
-	struct gatt_app *cl;
 
 	DBG("");
 
-	cl = queue_remove_if(gatt_apps, match_app_by_id,
-						INT_TO_PTR(cmd->client_if));
-	if (!cl) {
-		error("gatt: client_if=%d not found", cmd->client_if);
-		status = HAL_STATUS_FAILED;
-	} else {
-		/*
-		 * Check if there is any connect request or connected device
-		 * for this client. If so, remove this client from those lists.
-		 */
-		app_disconnect_devices(cl);
-		destroy_gatt_app(cl);
-		status = HAL_STATUS_SUCCESS;
-	}
+	status = unregister_client(cmd->client_if);
 
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
 					HAL_OP_GATT_CLIENT_UNREGISTER, status);
-- 
2.0.0.rc4


  parent reply	other threads:[~2014-05-26 21:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 21:53 [PATCH 0/5] android: GATT client test interface Szymon Janc
2014-05-26 21:53 ` [PATCH 1/5] android/gatt: Add initial implementation of client test command Szymon Janc
2014-05-26 21:53 ` Szymon Janc [this message]
2014-05-26 21:53 ` [PATCH 3/5] android/gatt: Implement enable " Szymon Janc
2014-05-26 21:53 ` [PATCH 4/5] android/gatt: Implement connect " Szymon Janc
2014-05-26 21:53 ` [PATCH 5/5] android/gatt: Implement disconnect " Szymon Janc
2014-05-28 12:45 ` [PATCH 0/5] android: GATT client test interface Szymon Janc

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=1401141208-26912-3-git-send-email-szymon.janc@gmail.com \
    --to=szymon.janc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).