diff mbox

totally untested attachment of device nodes to usb devices

Message ID 1320434511-4862-1-git-send-email-grant.likely@secretlab.ca
State New
Headers show

Commit Message

Grant Likely Nov. 4, 2011, 7:21 p.m. UTC
Proof of concept, needs to be made compilable and add the unwind path
on error and remove.

Bodged-together-by: Grant Likely <grant.likely@secretlab.ca>
---

Resend... I messed up Deepak's email addr.

g.

 drivers/usb/core/hub.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 96f05b2..bafd31d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1856,6 +1856,8 @@  fail:
  */
 int usb_new_device(struct usb_device *udev)
 {
+	struct device_node *np = udev->bus->dev.of_node;
+	struct device_node *child;
 	int err;
 
 	if (udev->parent) {
@@ -1864,6 +1866,17 @@  int usb_new_device(struct usb_device *udev)
 		 * sysfs power/wakeup controls wakeup enabled/disabled
 		 */
 		device_init_wakeup(&udev->dev, 0);
+
+		/* Grab the device node for the hub */
+		np = udev->parent->dev.of_node;
+	}
+
+	/* Do we have a device tree node for this USB device? */
+	if (np) {
+		for_each_child_of_node(child, np) {
+			if (value_of_reg_property(child) == udev->portnum)
+				udev->dev.of_node = of_node_get(child);
+		}
 	}
 
 	/* Tell the runtime-PM framework the device is active */