public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: alokbarsode@gmail.com
To: linux-bluetooth@vger.kernel.org
Cc: Alok Barsode <alok.barsode@azingo.com>
Subject: [PATCH 2/3] Adding resolve name functionality to hciops plugin.
Date: Tue, 23 Jun 2009 20:20:20 +0530	[thread overview]
Message-ID: <1245768621-22895-2-git-send-email-alok.barsode@azingo.com> (raw)
In-Reply-To: <1245768621-22895-1-git-send-email-alok.barsode@azingo.com>

From: Alok Barsode <alok.barsode@azingo.com>

---
 plugins/hciops.c |   24 ++++++++++++++++++++++++
 src/adapter.c    |   19 ++-----------------
 src/adapter.h    |    1 +
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index dae79b3..9a873fd 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -628,6 +628,29 @@ static int hciops_stop_discovery(int index)
 	return err;
 }
 
+static int hciops_resolve_name(int index, bdaddr_t *bdaddr)
+{
+	remote_name_req_cp cp;
+	int dd, err = 0;
+
+	dd = hci_open_dev(index);
+	if (dd < 0)
+		return -EIO;
+
+	memset(&cp, 0, sizeof(cp));
+	bacpy(&cp.bdaddr, bdaddr);
+	cp.pscan_rep_mode = 0x02;
+
+	err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_REMOTE_NAME_REQ,
+					REMOTE_NAME_REQ_CP_SIZE, &cp);
+	if (err < 0)
+		err = -errno;
+
+	hci_close_dev(dd);
+
+	return err;
+}
+
 static struct btd_adapter_ops hci_ops = {
 	.setup = hciops_setup,
 	.cleanup = hciops_cleanup,
@@ -639,6 +662,7 @@ static struct btd_adapter_ops hci_ops = {
 	.set_limited_discoverable = hciops_set_limited_discoverable,
 	.start_discovery = hciops_start_discovery,
 	.stop_discovery = hciops_stop_discovery,
+	.resolve_name = hciops_resolve_name,
 };
 
 static int hciops_init(void)
diff --git a/src/adapter.c b/src/adapter.c
index 9a913ac..cd5c1d0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -260,9 +260,8 @@ int pending_remote_name_cancel(struct btd_adapter *adapter)
 
 int adapter_resolve_names(struct btd_adapter *adapter)
 {
-	remote_name_req_cp cp;
 	struct remote_dev_info *dev, match;
-	int dd, err;
+	int err;
 
 	memset(&match, 0, sizeof(struct remote_dev_info));
 	bacpy(&match.bdaddr, BDADDR_ANY);
@@ -272,21 +271,12 @@ int adapter_resolve_names(struct btd_adapter *adapter)
 	if (!dev)
 		return -ENODATA;
 
-	dd = hci_open_dev(adapter->dev_id);
-	if (dd < 0)
-		return -errno;
-
 	/* send at least one request or return failed if the list is empty */
 	do {
 		/* flag to indicate the current remote name requested */
 		dev->name_status = NAME_REQUESTED;
 
-		memset(&cp, 0, sizeof(cp));
-		bacpy(&cp.bdaddr, &dev->bdaddr);
-		cp.pscan_rep_mode = 0x02;
-
-		err = hci_send_cmd(dd, OGF_LINK_CTL, OCF_REMOTE_NAME_REQ,
-						REMOTE_NAME_REQ_CP_SIZE, &cp);
+		err = adapter_ops->resolve_name(adapter->dev_id, &dev->bdaddr);
 
 		if (!err)
 			break;
@@ -302,11 +292,6 @@ int adapter_resolve_names(struct btd_adapter *adapter)
 		dev = adapter_search_found_devices(adapter, &match);
 	} while (dev);
 
-	hci_close_dev(dd);
-
-	if (err < 0)
-		err = errno;
-
 	return err;
 }
 
diff --git a/src/adapter.h b/src/adapter.h
index fca34eb..e087bb0 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -164,6 +164,7 @@ struct btd_adapter_ops {
 						gboolean limited);
 	int (*start_discovery) (int index, gboolean periodic);
 	int (*stop_discovery) (int index);
+	int (*resolve_name) (int index, bdaddr_t *bdaddr);
 };
 
 int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
-- 
1.5.6.3


  reply	other threads:[~2009-06-23 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23 14:50 [PATCH 1/3] Renaming found_device_req_name to adapter_resolve_names alokbarsode
2009-06-23 14:50 ` alokbarsode [this message]
2009-06-23 14:50   ` [PATCH 3/3] Adding cancel_resolve_name functionality to hciops plugin alokbarsode
2009-06-30 15:11 ` [PATCH 1/3] Renaming found_device_req_name to adapter_resolve_names Johan Hedberg
2009-07-02 14:21   ` 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=1245768621-22895-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