[RFC][Patch 2/3] bluetooth: Fix device_move() vs. dpm_list.

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

 



Make use of the new device_pm_move_*() functions when moving
bluetooth ttys. They either get a new parent or are moved to
head. (Note: I didn't bother to implement proper handling of
device_move() failures...)

Signed-off-by: Cornelia Huck <cornelia.huck@xxxxxxxxxx>

---
 net/bluetooth/hci_sysfs.c  |    5 ++++-
 net/bluetooth/rfcomm/tty.c |   21 ++++++++++++++++-----
 2 files changed, 20 insertions(+), 6 deletions(-)

--- linux-2.6.orig/net/bluetooth/rfcomm/tty.c
+++ linux-2.6/net/bluetooth/rfcomm/tty.c
@@ -730,8 +730,15 @@ static int rfcomm_tty_open(struct tty_st
 	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&dev->wait, &wait);
 
-	if (err == 0)
-		device_move(dev->tty_dev, rfcomm_get_device(dev));
+	if (err == 0) {
+		struct device *target = rfcomm_get_device(dev);
+
+		device_pm_lock();
+		/* FIXME: handle device_move() errors */
+		if (!device_move(dev->tty_dev, target))
+			device_pm_move_before(dev->tty_dev, target);
+		device_pm_unlock();
+	}
 
 	rfcomm_tty_copy_pending(dev);
 
@@ -750,9 +757,13 @@ static void rfcomm_tty_close(struct tty_
 						atomic_read(&dev->opened));
 
 	if (atomic_dec_and_test(&dev->opened)) {
-		if (dev->tty_dev->parent)
-			device_move(dev->tty_dev, NULL);
-
+		if (dev->tty_dev->parent) {
+			device_pm_lock();
+			/* FIXME: handle device_move errors */
+			if (!device_move(dev->tty_dev, NULL))
+				device_pm_move_last(dev->tty_dev);
+			device_pm_unlock();
+		}
 		/* Close DLC and dettach TTY */
 		rfcomm_dlc_close(dev->dlc, 0);
 
--- linux-2.6.orig/net/bluetooth/hci_sysfs.c
+++ linux-2.6/net/bluetooth/hci_sysfs.c
@@ -140,7 +140,10 @@ static void del_conn(struct work_struct 
 		dev = device_find_child(&conn->dev, NULL, __match_tty);
 		if (!dev)
 			break;
-		device_move(dev, NULL);
+		device_pm_lock();
+		if (!device_move(dev, NULL))
+			device_pm_move_last(dev);
+		device_pm_unlock();
 		put_device(dev);
 	}
 
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux