From patchwork Tue May 30 16:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9754869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0446602BF for ; Tue, 30 May 2017 16:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E296726538 for ; Tue, 30 May 2017 16:28:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D767727CEA; Tue, 30 May 2017 16:28:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AD3E26E49 for ; Tue, 30 May 2017 16:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751071AbdE3Q1l (ORCPT ); Tue, 30 May 2017 12:27:41 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:33651 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbdE3Q04 (ORCPT ); Tue, 30 May 2017 12:26:56 -0400 Received: by mail-lf0-f68.google.com with SMTP id m18so9326584lfj.0; Tue, 30 May 2017 09:26:50 -0700 (PDT) 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=uSycDJrIxoEcAacCODhYDUV19qy75okfb3hVld6BSV9LuVSQy+x97bZfmk2MbloJ2Q KpgBT1Qq2y5TQ0DYADibJWRoe82/V2+xqafMBAXApuID5W0lHti6cs6Asov+WtPbM3aK V7fA4Ophv1FS/91z+7oszMQyxxRbOEVHvMR8S6EPXD1aA1F+B0P7enpMFkFrv4kdYs2k 27AmGFcit8YPQHpBR+nLaZcef8fBBDyrRKJdQbRsn+6IPxwU12mOK43lDj5agmXV1KL6 F+js6aIe2Z/23F+u6zeIQT6nvuv4mrcOpsTdzTEOC/KwLg4xZSB9Z3W85Mx8xy0tauYf y8LA== 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=IoWOuvRvRUL4eeUJXlDsl9HFlZhnOPjrAdZvL+nnQGXkHSUdQwIeYtKphLy8BRVUxs 932WniozXTtWBh+Bd5A15X9PSqqKd27otWbhxyDtfJen2B374AjH9OWXfvfBjrobZNnS Ai9t6pXZKIQkZFjZYGmuw6TuS9S1O5T8D4P1g6PN1GQThtQWQ5EkWOXh43DR8AWNXjri x2AVTZ2dcXr1myCjcrVGpM1R9+DiPJSPrCAa+WGMJeWis/2F9lB3l9UAcjwdegMy0ox8 Ur4mwFyR6D8FSYp3d4vP0Hjq17fTpFkOvVJQqht4YGo1vOBHoFP2AN15IVngQhl5v5eQ iIWg== X-Gm-Message-State: AODbwcCxBI7mR/cysolEFofo9CLlXauJ3vuLBiUWatzvlp6b173ql+8B vLlZXoZ1mnuc/w== X-Received: by 10.25.18.165 with SMTP id 37mr6240961lfs.176.1496161609487; Tue, 30 May 2017 09:26:49 -0700 (PDT) Received: from xi.terra (c-42c8e255.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.226.200.66]) by smtp.gmail.com with ESMTPSA id h1sm2831053lfj.48.2017.05.30.09.26.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 09:26:47 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dFjyr-0006p8-DB; Tue, 30 May 2017 18:26:49 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Linus Walleij , Peter Chen , Rob Herring , Arnd Bergmann , Sricharan R , Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 5/7] USB: of: fix root-hub device-tree node handling Date: Tue, 30 May 2017 18:25:52 +0200 Message-Id: <20170530162554.26159-6-johan@kernel.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170530162554.26159-1-johan@kernel.org> References: <20170530162554.26159-1-johan@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 {