Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Szymon Janc <szymon.janc@tieto.com>
Subject: [PATCH 2/6] android: Add initial code for services unregister
Date: Wed, 23 Oct 2013 13:04:37 +0200	[thread overview]
Message-ID: <1382526281-19711-2-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1382526281-19711-1-git-send-email-szymon.janc@tieto.com>

This will be used to disable services on respective HAL cleanup calls.
---
 android/main.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/android/main.c b/android/main.c
index af7ebf3..73ff3ee 100644
--- a/android/main.c
+++ b/android/main.c
@@ -96,10 +96,15 @@ static void service_unregister(void *buf, uint16_t len)
 {
 	struct hal_msg_cmd_unregister_module *m = buf;
 
-	if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id]) {
-		ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE,
-							HAL_ERROR_FAILED);
-		return;
+	if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id])
+		goto error;
+
+	switch (m->service_id) {
+	default:
+		/* This would indicate bug in HAL, as unregister should not be
+		 * called in init failed */
+		DBG("service %u not supported", m->service_id);
+		goto error;
 	}
 
 	services[m->service_id] = false;
@@ -108,6 +113,9 @@ static void service_unregister(void *buf, uint16_t len)
 								0, NULL, -1);
 
 	info("Service ID=%u unregistered", m->service_id);
+	return;
+error:
+	ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_ERROR_FAILED);
 }
 
 static void handle_service_core(uint8_t opcode, void *buf, uint16_t len)
-- 
1.8.4


  reply	other threads:[~2013-10-23 11:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23 11:04 [PATCH 1/6] android: Add initial code for services register Szymon Janc
2013-10-23 11:04 ` Szymon Janc [this message]
2013-10-23 11:04 ` [PATCH 3/6] android: Add support for registering "bluetooth" service Szymon Janc
2013-10-23 11:04 ` [PATCH 4/6] android: Add bt_adapter_get_address function Szymon Janc
2013-10-23 11:04 ` [PATCH 5/6] android: Add initial code for socket service Szymon Janc
2013-10-23 11:04 ` [PATCH 6/6] android: Add support for registering and unregistering hid service Szymon Janc
2013-10-23 11:29 ` [PATCH 1/6] android: Add initial code for services register Johan Hedberg

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=1382526281-19711-2-git-send-email-szymon.janc@tieto.com \
    --to=szymon.janc@tieto.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