Blob Blame History Raw
From: Luiz Augusto von Dentz <luiz.dentz@openbossa.org>
Date: Fri, 24 Apr 2009 21:06:22 +0000 (-0300)
Subject: Fix bug which prevent input devices to work if bluetoothd is restarted.
X-Git-Tag: 4.38~30
X-Git-Url: http://git.kernel.org/?p=bluetooth%2Fbluez.git;a=commitdiff_plain;h=8ca76f2e9cf85ff39adc8bfa68627b8c4d9512cc

Fix bug which prevent input devices to work if bluetoothd is restarted.

In case of bluetoothd being restart or adapter unplugged the devices driver
callback .remove is called to free any data, but the input driver was also
sending the virtual cable unplug which is only necessary for permanent
removal.
---

diff --git a/input/device.c b/input/device.c
index 9f13cd5..aaf478b 100644
--- a/input/device.c
+++ b/input/device.c
@@ -781,10 +781,13 @@ static void disconnect_cb(struct btd_device *device, gboolean removal,
 				void *user_data)
 {
 	struct input_device *idev = user_data;
+	int flags;
 
 	info("Input: disconnect %s", idev->path);
 
-	disconnect(idev, 0);
+	flags = removal ? (1 << HIDP_VIRTUAL_CABLE_UNPLUG) : 0;
+
+	disconnect(idev, flags);
 }
 
 static int input_device_connected(struct input_device *idev,
@@ -1004,8 +1007,6 @@ static void device_unregister(void *data)
 	debug("Unregistered interface %s on path %s", INPUT_DEVICE_INTERFACE,
 								idev->path);
 
-	/* Disconnect if applied */
-	disconnect(idev, (1 << HIDP_VIRTUAL_CABLE_UNPLUG));
 	devices = g_slist_remove(devices, idev);
 	input_device_free(idev);
 }