linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <chen.ganir@ti.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: <chen.ganir@ti.com>
Subject: [PATCH] adapter: add API to find an existing device by D-Bus path
Date: Thu, 30 Aug 2012 15:09:02 +0300	[thread overview]
Message-ID: <1346328542-13203-1-git-send-email-chen.ganir@ti.com> (raw)

From: Chen Ganir <chen.ganir@ti.com>

This allows us to get a btd_device from information passed in D-Bus
method calls or signals.
---
 src/adapter.c |   15 +++++++++++++++
 src/adapter.h |    2 ++
 2 files changed, 17 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 50779fd..6aee982 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3479,6 +3479,21 @@ void adapter_bonding_complete(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	}
 }
 
+struct btd_device *adapter_get_device_by_path(struct btd_adapter *adapter,
+					      const char *path)
+{
+	GSList *l;
+
+	for (l = adapter->devices; l != NULL; l = g_slist_next(l))
+		if (g_strcmp0(device_get_path(l->data), path) == 0)
+			break;
+
+	if (!l)
+		return NULL;
+
+	return l->data;
+}
+
 int btd_adapter_read_local_oob_data(struct btd_adapter *adapter)
 {
 	return mgmt_read_local_oob_data(adapter->dev_id);
diff --git a/src/adapter.h b/src/adapter.h
index 5a0247e..6435dfb 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -232,3 +232,5 @@ int btd_adapter_gatt_server_start(struct btd_adapter *adapter);
 void btd_adapter_gatt_server_stop(struct btd_adapter *adapter);
 
 int btd_adapter_ssp_enabled(struct btd_adapter *adapter);
+struct btd_device *adapter_get_device_by_path(struct btd_adapter *adapter,
+					      const char *path);
-- 
1.7.9.5


             reply	other threads:[~2012-08-30 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-30 12:09 chen.ganir [this message]
2012-08-30 13:03 ` [PATCH] adapter: add API to find an existing device by D-Bus path Daniele Forsi

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=1346328542-13203-1-git-send-email-chen.ganir@ti.com \
    --to=chen.ganir@ti.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).