All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Rogers <brian@xyzw.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] Wait for child devices to go away before deleting a connection
Date: Mon, 20 Jul 2009 01:03:36 -0700	[thread overview]
Message-ID: <4A6424D8.3040306@xyzw.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

This patch fixes the device removal order when a connection is closed, 
which allows HAL to see the remove event and prevents a bunch of 
duplicate devices from piling up and eventually hitting the limit for 
the for input devices in X.

Posting for discussion since I used a polling loop (with a sleep) to 
wait for child devices to go away. I assume it'd be preferable to wait 
in a more proper way. In that case, before I start, is this the right 
place to be waiting?


[-- Attachment #2: 0001-Bluetooth-Wait-for-child-devices-to-go-away-before-d.patch --]
[-- Type: text/x-patch, Size: 1509 bytes --]

>From 2779df84b73363d309fad933b6fb00e1276e8ff7 Mon Sep 17 00:00:00 2001
From: Brian Rogers <brian@xyzw.org>
Date: Sun, 19 Jul 2009 03:43:24 -0700
Subject: [PATCH 1/2] Bluetooth: Wait for child devices to go away before deleting a connection.

---
 net/bluetooth/hci_sysfs.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 95f7a7a..ebb0d15 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -100,14 +100,9 @@ static void add_conn(struct work_struct *work)
 	hci_dev_hold(hdev);
 }
 
-/*
- * The rfcomm tty device will possibly retain even when conn
- * is down, and sysfs doesn't support move zombie device,
- * so we should move the device before conn device is destroyed.
- */
-static int __match_tty(struct device *dev, void *data)
+static int __match_any(struct device *dev, void *data)
 {
-	return !strncmp(dev_name(dev), "rfcomm", 6);
+	return 1;
 }
 
 static void del_conn(struct work_struct *work)
@@ -118,14 +113,16 @@ static void del_conn(struct work_struct *work)
 	if (!device_is_registered(&conn->dev))
 		return;
 
+	/* wait for child devices to go away first */
 	while (1) {
 		struct device *dev;
 
-		dev = device_find_child(&conn->dev, NULL, __match_tty);
+		dev = device_find_child(&conn->dev, NULL, __match_any);
 		if (!dev)
 			break;
-		device_move(dev, NULL, DPM_ORDER_DEV_LAST);
 		put_device(dev);
+
+		msleep(100);
 	}
 
 	device_del(&conn->dev);
-- 
1.6.3.3


             reply	other threads:[~2009-07-20  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-20  8:03 Brian Rogers [this message]
2009-07-20  8:10 ` [PATCH] Wait for child devices to go away before deleting a connection Marcel Holtmann
2009-07-23 13:25   ` Brian Rogers
2009-07-29 21:12     ` Marcel Holtmann
2009-07-29 22:37       ` Brian Rogers
2009-07-30  2:33         ` Marcel Holtmann
2009-07-30  3:25           ` Brian Rogers
2009-07-30  3:49             ` Marcel Holtmann
2009-07-30  5:24               ` Brian Rogers

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=4A6424D8.3040306@xyzw.org \
    --to=brian@xyzw.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.