Received: by 10.192.165.148 with SMTP id m20csp2242299imm; Thu, 26 Apr 2018 08:00:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp1iz77euwj/cj1abHY1KHRkbZUwrPygDs+YTAtlXaiSAaxaR1ajdqc5wi+3RVHpZsK0hU6 X-Received: by 2002:a17:902:b60b:: with SMTP id b11-v6mr6071811pls.330.1524754851711; Thu, 26 Apr 2018 08:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524754851; cv=none; d=google.com; s=arc-20160816; b=zjRn7SPr2vUPwTEKlcPlS6WjfGotERyyuIPSVS00x5v283OK//vPeBbB9JlEUW1lj2 uQKGC1tUnkflANSdUzD5tCsHGIOgBLfSR0v7ysEAhRLEeGmCwuyPuouqxLbE/g28r1oN cBl7zU8USserH3mB0yvzNCibGmh/rMfQ2GZSXYoXUJyknnQQk3uiCgtnVRaXtF+JQH/3 jOO5Jl7VQTqNFfqbPEqJWzhMTzVJLXLgpdZwgaH1k2GJq3BLqvQb53Lcfz2NV7G3XYy2 eqRLFVquKo7ZF4vEc1UEpzaoCmBTat9MLqhI4a1qgTboa/1+RdXto87hvLpML0AuzO7m g3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=ZAYbY+qQsRJNt8rnXpeaEc2N+9hgbrJE+MGnAA8HcGA=; b=JiWt6gC9gyGAPsq/sEcI9Bzxr2P81/ID0hAJY7UwIxuYPo9MXUBxuisDvmGfSzoOIY mPv3joMZwoeAEAbYMr+wCz3o//xdGxFS3VzLJngw2sGGs9tmyMwZUc7Kv2x6ZVZ0ZVBe WyDxrss8ZilQ7y2IVODq9a08ITUBuZjWHiBjjWa8pFXsY/QeQ1Ihy6hzY1BL5Hz3JMg6 S9Raf5+lqxEO+5a6DKU0M51OQPEGbngsTqEawa+Xy2MbRxwGxSsezzFo6gTus3DQNkOo rE4EIAXxp91QjydCnJJZmbMshojFBpJckzCLpytAr10H+PJvMNoK981FiJvE1RA2bzm4 6BeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b66-v6si17989014plb.107.2018.04.26.08.00.36; Thu, 26 Apr 2018 08:00:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756593AbeDZO71 (ORCPT + 99 others); Thu, 26 Apr 2018 10:59:27 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:13566 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755861AbeDZO7S (ORCPT ); Thu, 26 Apr 2018 10:59:18 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Thu, 26 Apr 2018 07:59:30 -0700 Received: from HQMAIL106.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 26 Apr 2018 07:59:17 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 26 Apr 2018 07:59:17 -0700 Received: from HQMAIL102.nvidia.com (172.18.146.10) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 26 Apr 2018 14:59:17 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL102.nvidia.com (172.18.146.10) with Microsoft SMTP Server id 15.0.1347.2 via Frontend Transport; Thu, 26 Apr 2018 14:59:17 +0000 Received: from moonraker.nvidia.com (Not Verified[10.21.132.129]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Thu, 26 Apr 2018 07:59:16 -0700 From: Jon Hunter To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding CC: , , , Jon Hunter Subject: [PATCH V2 1/3] usb: xhci: tegra: Prepare for adding runtime PM support Date: Thu, 26 Apr 2018 15:59:08 +0100 Message-ID: <1524754750-3633-1-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When adding runtime PM support to the Tegra XHCI driver, it is desirable to move the function calls to enable the clocks, regulators and PHY from the tegra_xusb_probe into the runtime PM handlers. Currently, the clocks, regulators and PHY are all enabled before we call usb_create_hcd() in tegra_xusb_probe(), however, we cannot call pm_runtime_get_sync() at this point because the platform device data is not yet initialised. Fortunately, the function usb_create_hcd() can be called before we enable the clocks, regulators and PHY and so prepare for adding runtime PM support, by moving the call to usb_create_hcd() before we enable the hardware. Signed-off-by: Jon Hunter --- Changes since V1: - None drivers/usb/host/xhci-tegra.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c index 2c076ea80522..02b0b24faa58 100644 --- a/drivers/usb/host/xhci-tegra.c +++ b/drivers/usb/host/xhci-tegra.c @@ -1054,10 +1054,23 @@ static int tegra_xusb_probe(struct platform_device *pdev) } } + tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, + dev_name(&pdev->dev)); + if (!tegra->hcd) { + err = -ENOMEM; + goto put_padctl; + } + + /* + * This must happen after usb_create_hcd(), because usb_create_hcd() + * will overwrite the drvdata of the device with the hcd it creates. + */ + platform_set_drvdata(pdev, tegra); + err = tegra_xusb_clk_enable(tegra); if (err) { dev_err(&pdev->dev, "failed to enable clocks: %d\n", err); - goto put_padctl; + goto put_usb2; } err = regulator_bulk_enable(tegra->soc->num_supplies, tegra->supplies); @@ -1080,19 +1093,6 @@ static int tegra_xusb_probe(struct platform_device *pdev) goto disable_phy; } - tegra->hcd = usb_create_hcd(&tegra_xhci_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!tegra->hcd) { - err = -ENOMEM; - goto disable_phy; - } - - /* - * This must happen after usb_create_hcd(), because usb_create_hcd() - * will overwrite the drvdata of the device with the hcd it creates. - */ - platform_set_drvdata(pdev, tegra); - tegra->hcd->regs = tegra->regs; tegra->hcd->rsrc_start = regs->start; tegra->hcd->rsrc_len = resource_size(regs); @@ -1100,7 +1100,7 @@ static int tegra_xusb_probe(struct platform_device *pdev) err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED); if (err < 0) { dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err); - goto put_usb2; + goto disable_phy; } device_wakeup_enable(tegra->hcd->self.controller); @@ -1155,14 +1155,14 @@ static int tegra_xusb_probe(struct platform_device *pdev) usb_put_hcd(xhci->shared_hcd); remove_usb2: usb_remove_hcd(tegra->hcd); -put_usb2: - usb_put_hcd(tegra->hcd); disable_phy: tegra_xusb_phy_disable(tegra); disable_regulator: regulator_bulk_disable(tegra->soc->num_supplies, tegra->supplies); disable_clk: tegra_xusb_clk_disable(tegra); +put_usb2: + usb_put_hcd(tegra->hcd); put_padctl: tegra_xusb_padctl_put(tegra->padctl); return err; -- 2.7.4