[PATCH BlueZ 02/12] Add a function to remove ATT connection callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/attio.h  |    2 ++
 src/device.c |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/attio.h b/src/attio.h
index fad8516..7935dcd 100644
--- a/src/attio.h
+++ b/src/attio.h
@@ -27,3 +27,5 @@ typedef void (*attio_connect_cb) (GAttrib *attrib, gpointer user_data);
 guint btd_device_add_attio_callback(struct btd_device *device,
 						attio_connect_cb func,
 						gpointer user_data);
+
+gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id);
diff --git a/src/device.c b/src/device.c
index b0d9c30..f22a7fa 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2469,3 +2469,30 @@ guint btd_device_add_attio_callback(struct btd_device *device,
 
 	return attio->id;
 }
+
+static int attio_id_cmp(gconstpointer a, gconstpointer b)
+{
+	const struct attio_data *attio = a;
+	guint id = GPOINTER_TO_UINT(b);
+
+	return attio->id - id;
+}
+
+gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id)
+{
+	struct attio_data *attio;
+	GSList *l;
+
+	l = g_slist_find_custom(device->attios, GUINT_TO_POINTER(id),
+								attio_id_cmp);
+	if (!l)
+		return FALSE;
+
+	attio = l->data;
+
+	device->attios = g_slist_remove(device->attios, attio);
+
+	g_free(attio);
+
+	return TRUE;
+}
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux