From: Dmitriy Paliy <dmitriy.paliy@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Daniel Orstadius <daniel.orstadius@nokia.com>
Subject: [PATCH] Remove driver only if remote has no matching UUID
Date: Sun, 13 Nov 2011 20:25:30 +0200 [thread overview]
Message-ID: <1321208730-22957-2-git-send-email-dmitriy.paliy@nokia.com> (raw)
In-Reply-To: <1321208730-22957-1-git-send-email-dmitriy.paliy@nokia.com>
From: Daniel Orstadius <daniel.orstadius@nokia.com>
Service discovery may generate a list of removed UUIDs. Previously
BlueZ promptly removed the btd_device_driver mapped to each
missing UUID.
With this patch it first checks if the remote has any remaining
UUID mapped to the driver, since each driver is used for several
UUIDs.
In case the driver is kept, the interface corresponding to the UUID
will not be removed (the patch deletes too little instead of too
much).
---
src/device.c | 63 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/src/device.c b/src/device.c
index d624b46..f7bff75 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1187,29 +1187,6 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
records = read_records(&src, &device->bdaddr);
- DBG("Removing drivers for %s", dstaddr);
-
- for (list = device->drivers; list; list = next) {
- struct btd_device_driver *driver = list->data;
- const char **uuid;
-
- next = list->next;
-
- for (uuid = driver->uuids; *uuid; uuid++) {
- if (!g_slist_find_custom(uuids, *uuid,
- (GCompareFunc) strcasecmp))
- continue;
-
- DBG("UUID %s was removed from device %s",
- *uuid, dstaddr);
-
- driver->remove(device);
- device->drivers = g_slist_remove(device->drivers,
- driver);
- break;
- }
- }
-
for (list = uuids; list; list = list->next) {
sdp_record_t *rec;
@@ -1228,6 +1205,46 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
if (records)
sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
+
+ DBG("Checking if drivers need to be removed for %s", dstaddr);
+
+ for (list = device->drivers; list; list = next) {
+ struct btd_device_driver *driver = list->data;
+ const char **uuid;
+
+ next = list->next;
+
+ for (uuid = driver->uuids; *uuid; uuid++) {
+ const char **uuid2;
+ gboolean found = FALSE;
+
+ if (!g_slist_find_custom(uuids, *uuid,
+ (GCompareFunc) strcasecmp))
+ continue;
+
+ DBG("UUID %s was removed from device %s",
+ *uuid, dstaddr);
+
+ /* check if there is any uuid for the driver
+ on the remote */
+ for (uuid2 = driver->uuids; *uuid2; uuid2++) {
+ if (g_slist_find_custom(device->uuids, *uuid2,
+ (GCompareFunc) strcasecmp)) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ error("Removing driver for %s", *uuid);
+ driver->remove(device);
+ device->drivers = g_slist_remove(
+ device->drivers, driver);
+ }
+
+ break;
+ }
+ }
}
static void services_changed(struct btd_device *device)
--
1.6.0.4
next prev parent reply other threads:[~2011-11-13 18:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-13 18:25 [PATCH 0/1] Remove driver only if remote has no matching UUID Dmitriy Paliy
2011-11-13 18:25 ` Dmitriy Paliy [this message]
2011-11-14 12:03 ` [PATCH] " Johan Hedberg
2011-11-15 2:30 ` Marcel Holtmann
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=1321208730-22957-2-git-send-email-dmitriy.paliy@nokia.com \
--to=dmitriy.paliy@gmail.com \
--cc=daniel.orstadius@nokia.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