From: alokbarsode@gmail.com
To: linux-bluetooth@vger.kernel.org
Cc: Alok Barsode <alok.barsode@azingo.com>
Subject: [PATCH 2/2] Adding read_name to hciops plugin.
Date: Wed, 8 Jul 2009 21:31:29 +0530 [thread overview]
Message-ID: <1247068889-7116-2-git-send-email-alok.barsode@azingo.com> (raw)
In-Reply-To: <1247068889-7116-1-git-send-email-alok.barsode@azingo.com>
From: Alok Barsode <alok.barsode@azingo.com>
---
plugins/hciops.c | 19 +++++++++++++++++++
src/adapter.c | 13 +++----------
src/adapter.h | 1 +
3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 858a346..7a6ff42 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -704,6 +704,24 @@ static int hciops_change_name(int index, const char *name)
return err;
}
+static int hciops_read_name(int index)
+{
+ int dd, err = 0;
+
+ dd = hci_open_dev(index);
+ if (dd < 0)
+ return -EIO;
+
+ err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_READ_LOCAL_NAME, 0, 0);
+
+ if (err < 0)
+ err = -errno;
+
+ hci_close_dev(dd);
+
+ return err;
+}
+
static int hciops_cancel_resolve_name(int index, bdaddr_t *bdaddr)
{
remote_name_req_cancel_cp cp;
@@ -740,6 +758,7 @@ static struct btd_adapter_ops hci_ops = {
.resolve_name = hciops_resolve_name,
.cancel_resolve_name = hciops_cancel_resolve_name,
.change_name = hciops_change_name,
+ .read_name = hciops_read_name,
};
static int hciops_init(void)
diff --git a/src/adapter.c b/src/adapter.c
index 9569f2a..37f4495 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -877,7 +877,7 @@ void adapter_update_local_name(bdaddr_t *bdaddr, uint8_t status, void *ptr)
void adapter_setname_complete(bdaddr_t *local, uint8_t status)
{
struct btd_adapter *adapter;
- int dd, err;
+ int err;
if (status)
return;
@@ -888,18 +888,11 @@ void adapter_setname_complete(bdaddr_t *local, uint8_t status)
return;
}
- dd = hci_open_dev(adapter->dev_id);
- if (dd < 0) {
- error("HCI device open failed: hci%d", adapter->dev_id);
- return;
- }
-
- err = hci_send_cmd(dd, OGF_HOST_CTL, OCF_READ_LOCAL_NAME, 0, 0);
+ err = adapter_ops->read_name(adapter->dev_id);
if (err < 0)
error("Sending getting name command failed: %s (%d)",
strerror(errno), errno);
- hci_close_dev(dd);
}
static DBusMessage *set_name(DBusConnection *conn, DBusMessage *msg,
@@ -2132,7 +2125,7 @@ int adapter_start(struct btd_adapter *adapter)
return err;
}
- hci_send_cmd(dd, OGF_HOST_CTL, OCF_READ_LOCAL_NAME, 0, 0);
+ adapter_ops->read_name(adapter->dev_id);
if (!(features[6] & LMP_SIMPLE_PAIR))
goto setup;
diff --git a/src/adapter.h b/src/adapter.h
index eb513fb..65dafef 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -174,6 +174,7 @@ struct btd_adapter_ops {
int (*resolve_name) (int index, bdaddr_t *bdaddr);
int (*cancel_resolve_name) (int index, bdaddr_t *bdaddr);
int (*change_name) (int index, const char *name);
+ int (*read_name) (int index);
};
int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
--
1.5.6.3
next prev parent reply other threads:[~2009-07-08 16:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-08 16:01 [PATCH 1/2] Adding change_name to hciops plugin alokbarsode
2009-07-08 16:01 ` alokbarsode [this message]
2009-07-13 9:39 ` [PATCH 2/2] Adding read_name " Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2009-07-10 9:46 [PATCH 1/2] Adding set_name " alokbarsode
2009-07-10 9:46 ` [PATCH 2/2] Adding read_name " alokbarsode
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=1247068889-7116-2-git-send-email-alok.barsode@azingo.com \
--to=alokbarsode@gmail.com \
--cc=alok.barsode@azingo.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