* [PATCH] Fix unblock removed device
@ 2010-06-28 11:00 Daniel Örstadius
2010-06-28 22:27 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Örstadius @ 2010-06-28 11:00 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
This patch unblocks a device when removing it. Adds boolean argument
to function device_unblock to only emit property changed signal and
probe drivers when unblocking a device if the device is not unblocked
as part of being removed.
/Daniel
[-- Attachment #2: 0001-Fix-unblock-removed-device.patch --]
[-- Type: text/x-patch, Size: 2366 bytes --]
From 5da37821d8bcf47d0734e7d7aaa27d81c9102380 Mon Sep 17 00:00:00 2001
From: Daniel Orstadius <daniel.orstadius@gmail.com>
Date: Mon, 28 Jun 2010 13:45:37 +0300
Subject: [PATCH] Fix unblock removed device
Unblocks a device when removing it. Adds boolean argument to
function device_unblock to only emit property changed signal and
probe drivers when unblocking a device if the device is not
unblocked as part of being removed.
---
src/device.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/device.c b/src/device.c
index 11b1fd2..6deb4a2 100644
--- a/src/device.c
+++ b/src/device.c
@@ -513,7 +513,7 @@ static int device_block(DBusConnection *conn, struct btd_device *device)
return 0;
}
-static int device_unblock(DBusConnection *conn, struct btd_device *device)
+static int device_unblock(DBusConnection *conn, struct btd_device *device, gboolean silent)
{
int dev_id, dd, err;
bdaddr_t src;
@@ -543,10 +543,12 @@ static int device_unblock(DBusConnection *conn, struct btd_device *device)
if (err < 0)
error("write_blocked(): %s (%d)", strerror(-err), -err);
- emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Blocked",
- DBUS_TYPE_BOOLEAN, &device->blocked);
+ if (!silent) {
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Blocked",
+ DBUS_TYPE_BOOLEAN, &device->blocked);
- device_probe_drivers(device, device->uuids);
+ device_probe_drivers(device, device->uuids);
+ }
return 0;
}
@@ -560,7 +562,7 @@ static DBusMessage *set_blocked(DBusConnection *conn, DBusMessage *msg,
if (value)
err = device_block(conn, device);
else
- err = device_unblock(conn, device);
+ err = device_unblock(conn, device, FALSE);
switch (-err) {
case 0:
@@ -1100,6 +1102,7 @@ static void device_remove_stored(struct btd_device *device)
{
bdaddr_t src;
char addr[18];
+ DBusConnection *conn = get_dbus_connection();
adapter_get_address(device->adapter, &src);
ba2str(&device->bdaddr, addr);
@@ -1109,6 +1112,9 @@ static void device_remove_stored(struct btd_device *device)
delete_entry(&src, "profiles", addr);
delete_entry(&src, "trusts", addr);
delete_all_records(&src, &device->bdaddr);
+
+ if (device->blocked)
+ device_unblock(conn, device, TRUE);
}
void device_remove(struct btd_device *device, gboolean remove_stored)
--
1.6.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix unblock removed device
2010-06-28 11:00 [PATCH] Fix unblock removed device Daniel Örstadius
@ 2010-06-28 22:27 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-06-28 22:27 UTC (permalink / raw)
To: Daniel Örstadius; +Cc: linux-bluetooth
Hi Daniel,
On Mon, Jun 28, 2010, Daniel Örstadius wrote:
> This patch unblocks a device when removing it. Adds boolean argument
> to function device_unblock to only emit property changed signal and
> probe drivers when unblocking a device if the device is not unblocked
> as part of being removed.
Thanks for the patch. It has now been pushed upstream with a couple of
over 80 character line fixes. Please pay attention to that in the
future.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-28 22:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 11:00 [PATCH] Fix unblock removed device Daniel Örstadius
2010-06-28 22:27 ` Johan Hedberg
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).