From: Szymon Janc <szymon.janc@tieto.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: Szymon Janc <szymon.janc@gmail.com>
Subject: [PATCH v2 2/5] android: Fix bt_adapter_init
Date: Thu, 24 Oct 2013 11:54:21 +0200 [thread overview]
Message-ID: <1382608464-10389-2-git-send-email-szymon.janc@tieto.com> (raw)
In-Reply-To: <1382608464-10389-1-git-send-email-szymon.janc@tieto.com>
From: Szymon Janc <szymon.janc@gmail.com>
Make bt_adapter_init return void and use ready callback for error
reporting. This also fix returning incorrect status and invalid
mgmt_if unref (mgmt_send return 0 on error or >0 on success).
---
android/adapter.c | 15 +++++++--------
android/adapter.h | 4 ++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/android/adapter.c b/android/adapter.c
index 88ac19f..79cfcfd 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -277,8 +277,8 @@ failed:
adapter->ready(NULL, err);
}
-bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
- bt_adapter_ready ready)
+void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
+ bt_adapter_ready cb)
{
struct bt_adapter *adapter;
@@ -286,15 +286,14 @@ bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
adapter->mgmt = mgmt_ref(mgmt_if);
adapter->index = index;
- adapter->ready = ready;
+ adapter->ready = cb;
if (mgmt_send(mgmt_if, MGMT_OP_READ_INFO, index, 0, NULL,
- read_info_complete, adapter, NULL) > 0) {
- mgmt_unref(mgmt_if);
- return false;
- }
+ read_info_complete, adapter, NULL) > 0)
+ return;
- return adapter;
+ mgmt_unref(mgmt_if);
+ adapter->ready(-EIO);
}
static void set_mode_complete(uint8_t status, uint16_t length,
diff --git a/android/adapter.h b/android/adapter.h
index b8d0a58..236f10a 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -32,8 +32,8 @@ struct bt_adapter;
typedef void (*bt_adapter_ready)(struct bt_adapter *adapter, int err);
-bool bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
- bt_adapter_ready func);
+void bt_adapter_init(uint16_t index, struct mgmt *mgmt_if,
+ bt_adapter_ready cb);
void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
uint16_t len);
--
1.8.4
next prev parent reply other threads:[~2013-10-24 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 9:54 [PATCH v2 1/5] android: Start command watch after notify channel is connected Szymon Janc
2013-10-24 9:54 ` Szymon Janc [this message]
2013-10-24 9:54 ` [PATCH v2 3/5] android: Remove not needed adapter parameter from bt_adapter_ready Szymon Janc
2013-10-24 9:54 ` [PATCH v2 4/5] android: Use default adapter in adapter functions Szymon Janc
2013-10-24 9:54 ` [PATCH v2 5/5] android: Use adapter index in mgmt functions Szymon Janc
2013-10-24 15:34 ` [PATCH v2 1/5] android: Start command watch after notify channel is connected Luiz Augusto von Dentz
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=1382608464-10389-2-git-send-email-szymon.janc@tieto.com \
--to=szymon.janc@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@gmail.com \
/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