linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel Örstadius" <daniel.orstadius@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] Fix unblock removed device
Date: Mon, 28 Jun 2010 14:00:21 +0300	[thread overview]
Message-ID: <AANLkTil1_LwZYuTuZT0gQgd7Mxjo0CoY2WVI8CW-f-wj@mail.gmail.com> (raw)

[-- 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


             reply	other threads:[~2010-06-28 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-28 11:00 Daniel Örstadius [this message]
2010-06-28 22:27 ` [PATCH] Fix unblock removed device 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=AANLkTil1_LwZYuTuZT0gQgd7Mxjo0CoY2WVI8CW-f-wj@mail.gmail.com \
    --to=daniel.orstadius@gmail.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).