Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1658889

[PATCH v2 5/7] USB: of: fix root-hub device-tree node handling

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Johan Hovold <johan@kernel.org>
Newsgroups linux.kernel
Subject [PATCH v2 5/7] USB: of: fix root-hub device-tree node handling
Date Tue, 06 Jun 2017 18:10:01 +0200
Message-ID <tPpdn-2Df-3@gated-at.bofh.it> (permalink)
References <tPpdn-2Df-5@gated-at.bofh.it>
X-Original-To Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jSiku5flXzxis+xJCnbi6aePQ1/GxUMrxaTppiWo7dQ=; b=QOyFbEcg90/LLbYrKgK0qbMyN04YQjN8zrKMcir4bv+b+lRYA5JzIlf4ingGab6+y1 20fDJXZZt9Sfd43YV17quqe/wzpm84myoLs3W5RrGv1gGvXVBcQ5iC1ec6GO2je3W1w3 PQyIOUnqOgfpgXHJ/C0ADAij/94ogUXuhtMnOr+DWXXdZZAyjwsMe/aE05n9zddg6g+l w5GP9rbqBTYwbFwT4HdUb4KZLt4nMfYyC/R+nRw0r3A+E09KFA34bWaMHNCDxGntyRQZ jSJuDbKq5FB7dqkQt2pPzZOwobauAzfU1liVASYG8Ulr851mmQQAbRKgQqy5s2KvnemQ DiVw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jSiku5flXzxis+xJCnbi6aePQ1/GxUMrxaTppiWo7dQ=; b=XLc3EPDVo8TWEGR1+sXUivIE1l+pM7/gEG9uq/dXsM5U1IHbdZoRR/0wZKmd1jvC4g DFtKW2a16NZm2mWhjuhdfPqhLI6xpzDoEbXDloxnCswcXbpb9Am0wtwZXv5tBfxiD8er SNG38Md7s3Gem39KIA/hj6fWkCElGZYVz5Nf1H0zSSrUzdtDjmqtBltOaU5uzhNtPbQx zG96I+h5g++UaTRI/2CIXP+1kzR8HKMO58k8zRUEsTK6sT1EMOPTAmCMDqXVU4AAMU71 b3ztpn1acVKs2JgGgpZO6D5Dyi3LZEZgmQG8i8yY7vW8bfuFvbkUOIHI0gqV3RXrBUOo 653w==
X-Gm-Message-State AODbwcA4Xjfi5iGJDTyxXJPqNgLpgcGOqwrhTIeKOeOmINwO4YzFrYo4 qfE2Wc7LvkdvUA==
X-Received by 10.25.31.9 with SMTP id f9mr6734338lff.160.1496764850112; Tue, 06 Jun 2017 09:00:50 -0700 (PDT)
X-Mailer git-send-email 2.13.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 66
Organization linux.* mail to news gateway
X-Original-Cc Linus Walleij <linus.walleij@linaro.org>, Peter Chen <peter.chen@nxp.com>, Rob Herring <robh@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Sricharan R <sricharan@codeaurora.org>, Zhang Rui <rui.zhang@intel.com>, Eduardo Valentin <edubezval@gmail.com>, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold <johan@kernel.org>
X-Original-Date Tue, 6 Jun 2017 17:59:02 +0200
X-Original-Message-ID <20170606155904.26819-6-johan@kernel.org>
X-Original-References <20170606155904.26819-1-johan@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1658889

Show key headers only | View raw


In an attempt to work around a pinmux over-allocation issue in driver
core, commit dc5878abf49c ("usb: core: move root hub's device node
assignment after it is added to bus") moved the device-tree node
assignment until after the root hub had been registered.

This not only makes the device-tree node unavailable to the usb driver
during probe, but also prevents the of_node from being linked to in
sysfs and causes a race with user-space for the (recently added) devspec
attribute.

Use the new device_set_of_node_from_dev() helper to reuse the node of
the sysdev device, something which now prevents driver core from trying
to reclaim any pinctrl pins during probe.

Fixes: dc5878abf49c ("usb: core: move root hub's device node assignment after it is added to bus")
Fixes: 51fa91475e43 ("usb/core: Added devspec sysfs entry for devices behind the usb hub")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/core/hcd.c | 2 --
 drivers/usb/core/usb.c | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5dea98358c05..2cff59e9c268 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1076,7 +1076,6 @@ static void usb_deregister_bus (struct usb_bus *bus)
 static int register_root_hub(struct usb_hcd *hcd)
 {
 	struct device *parent_dev = hcd->self.controller;
-	struct device *sysdev = hcd->self.sysdev;
 	struct usb_device *usb_dev = hcd->self.root_hub;
 	const int devnum = 1;
 	int retval;
@@ -1123,7 +1122,6 @@ static int register_root_hub(struct usb_hcd *hcd)
 		/* Did the HC die before the root hub was registered? */
 		if (HCD_DEAD(hcd))
 			usb_hc_died (hcd);	/* This time clean up */
-		usb_dev->dev.of_node = sysdev->of_node;
 	}
 	mutex_unlock(&usb_bus_idr_lock);
 
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 62e1906bb2f3..17681d5638ac 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -416,8 +416,7 @@ static void usb_release_dev(struct device *dev)
 
 	usb_destroy_configuration(udev);
 	usb_release_bos_descriptor(udev);
-	if (udev->parent)
-		of_node_put(dev->of_node);
+	of_node_put(dev->of_node);
 	usb_put_hcd(hcd);
 	kfree(udev->product);
 	kfree(udev->manufacturer);
@@ -616,6 +615,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
 		dev->route = 0;
 
 		dev->dev.parent = bus->controller;
+		device_set_of_node_from_dev(&dev->dev, bus->sysdev);
 		dev_set_name(&dev->dev, "usb%d", bus->busnum);
 		root_hub = 1;
 	} else {
-- 
2.13.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v2 5/7] USB: of: fix root-hub device-tree node handling Johan Hovold <johan@kernel.org> - 2017-06-06 18:10 +0200

csiph-web