From patchwork Fri Nov 4 19:20:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 4941 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 35C4423E08 for ; Fri, 4 Nov 2011 19:20:49 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 28131A1816F for ; Fri, 4 Nov 2011 19:20:49 +0000 (UTC) Received: by faan26 with SMTP id n26so4369125faa.11 for ; Fri, 04 Nov 2011 12:20:49 -0700 (PDT) Received: by 10.152.145.233 with SMTP id sx9mr1350863lab.6.1320434448834; Fri, 04 Nov 2011 12:20:48 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.14.103 with SMTP id o7cs139864lac; Fri, 4 Nov 2011 12:20:48 -0700 (PDT) Received: by 10.150.199.12 with SMTP id w12mr5702099ybf.0.1320434440915; Fri, 04 Nov 2011 12:20:40 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id w17si1838450ybb.38.2011.11.04.12.20.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Nov 2011 12:20:40 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of glikely@secretlab.ca) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of glikely@secretlab.ca) smtp.mail=glikely@secretlab.ca Received: by ywa8 with SMTP id 8so3243417ywa.37 for ; Fri, 04 Nov 2011 12:20:40 -0700 (PDT) Received: by 10.236.75.225 with SMTP id z61mr23313738yhd.1.1320434440217; Fri, 04 Nov 2011 12:20:40 -0700 (PDT) Received: from localhost ([71.46.235.243]) by mx.google.com with ESMTPS id 8sm30432932anv.16.2011.11.04.12.20.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Nov 2011 12:20:39 -0700 (PDT) Sender: Grant Likely Received: by localhost (Postfix, from userid 1000) id 025BE3E09DF; Fri, 4 Nov 2011 15:20:38 -0400 (EDT) From: Grant Likely To: deepak.saxena@linaro.ort, patches@linaro.org, linaro-kernel@lists.linaro.org Cc: Grant Likely Subject: [PATCH] totally untested attachment of device nodes to usb devices Date: Fri, 4 Nov 2011 15:20:38 -0400 Message-Id: <1320434438-4803-1-git-send-email-grant.likely@secretlab.ca> X-Mailer: git-send-email 1.7.5.4 Proof of concept, needs to be made compilable and add the unwind path on error and remove. Bodged-together-by: Grant Likely --- Hi Deepak, Here's the code I hacked together on Friday. It would be useful to have someone take on this work and finish it so that device nodes can be attached to usb devices. g. drivers/usb/core/hub.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) 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 */