Linux bluetooth development
 help / color / mirror / Atom feed
From: Andre Guedes <andre.guedes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] hog: Fix removing HoG device bug
Date: Mon, 17 Dec 2012 16:03:23 -0300	[thread overview]
Message-ID: <1355771003-2518-1-git-send-email-andre.guedes@openbossa.org> (raw)

We should remove only hog_devices from the given btd_device.
Otherwise, all hog_devices will be removed.
---
 profiles/input/hog_device.c  | 5 +++++
 profiles/input/hog_device.h  | 1 +
 profiles/input/hog_manager.c | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index 06dab6d..cc68080 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
@@ -789,3 +789,8 @@ int hog_device_set_control_point(struct hog_device *hogdev, gboolean suspend)
 
 	return 0;
 }
+
+struct btd_device *hog_device_get_device(struct hog_device *hogdev)
+{
+	return hogdev->device;
+}
diff --git a/profiles/input/hog_device.h b/profiles/input/hog_device.h
index d1bfc08..60c4f12 100644
--- a/profiles/input/hog_device.h
+++ b/profiles/input/hog_device.h
@@ -31,3 +31,4 @@ struct hog_device *hog_device_register(struct btd_device *device,
 						struct gatt_primary *prim);
 int hog_device_unregister(struct hog_device *hogdev);
 int hog_device_set_control_point(struct hog_device *hogdev, gboolean suspend);
+struct btd_device *hog_device_get_device(struct hog_device *hogdev);
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 595b160..c7b98c5 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -106,6 +106,9 @@ static int hog_device_probe(struct btd_profile *p, struct btd_device *device,
 
 static void remove_device(gpointer hogdev, gpointer b)
 {
+	if (hog_device_get_device(hogdev) != b)
+		return;
+
 	devices = g_slist_remove(devices, hogdev);
 	hog_device_unregister(hogdev);
 }
@@ -116,7 +119,7 @@ static void hog_device_remove(struct btd_profile *p, struct btd_device *device)
 
 	DBG("path %s", path);
 
-	g_slist_foreach(devices, remove_device, NULL);
+	g_slist_foreach(devices, remove_device, device);
 }
 
 static struct btd_profile hog_profile = {
-- 
1.8.0.1


             reply	other threads:[~2012-12-17 19:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-17 19:03 Andre Guedes [this message]
2012-12-17 20:20 ` [PATCH BlueZ] hog: Fix removing HoG device bug Andre Guedes

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=1355771003-2518-1-git-send-email-andre.guedes@openbossa.org \
    --to=andre.guedes@openbossa.org \
    --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