Received: by 10.223.185.116 with SMTP id b49csp1132904wrg; Wed, 14 Feb 2018 12:07:57 -0800 (PST) X-Google-Smtp-Source: AH8x224epEbqlVRXATo2aIaKMa1UNXeUx+ypQPiI4aK//BMGKvkTJBOLzH04Aidiiw3J2yCU2VLf X-Received: by 2002:a17:902:44:: with SMTP id 62-v6mr167059pla.193.1518638877225; Wed, 14 Feb 2018 12:07:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518638877; cv=none; d=google.com; s=arc-20160816; b=zHvODXbmllKFFEyKbwLLJSbjy6PGwTbVn5NEdZYed97uPuUvysGudcqy/w0jYtOVnB zzcfwXQGfxXnMTuaM5AiFFGB2m9eP6ldhmporDxgl1KSRIPHISwGFCim8WWgiL8Rra0k JTSw+7HXjo/njnjsIDien5qIi57fV1EUDLvYzdKu06oRX9tQBvaJI68J1LSkRzrD/PaB TJ8Y7JzS/VuuBuqG3lSqRJ+sWd26SGPAy6yjfDNX9fZdb1TeTWxiz0NAS5wtKGJFtfWw waLZ+02T1rGj824n6HbSm0SU2olHLV6q96n4N7diiQ0cHXn7QzVKRODqD5x17q9DVCZY 6WSg== 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=XHmapOsOvkpHWbUn64XeEXP4Iq7CXquOe8kDmHzcKK4=; b=hw+UBBXoruIzyC5iFUVbpR5uqipBGNGdGn645jWEnjOz7lIoIgfuaSrwCCxdV8fMDB z8UYEZ+u53mfyo3ml0ZuzIge/4OMjFPwRCCOirflFdqLTYAr4MbZTz1/4vrDOfcBJQUI 3eQVNZ7H1uR1bhbOMvt4i1m/t4pMV8qfV6r5//Skw4Uk6yLoZ0V0zKdFjCNm5eK4ymtb OqXKApfQaU7lVD3vuVhDywr+dTB6e+TqkhfiOURsKy0j2RiDG2PZfNvURXF5TE9ePCpN 2p3KY5cjBfgey6OBPlxPWHQvdx6bsdpOvwx7MCBxIVNvznncUqNs/sjOoSYGneyfMuJf rrNA== 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 e12si6609737pgu.56.2018.02.14.12.07.42; Wed, 14 Feb 2018 12:07:57 -0800 (PST) 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 S1032663AbeBNQfE (ORCPT + 99 others); Wed, 14 Feb 2018 11:35:04 -0500 Received: from hqemgate15.nvidia.com ([216.228.121.64]:4808 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032583AbeBNQfC (ORCPT ); Wed, 14 Feb 2018 11:35:02 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Wed, 14 Feb 2018 08:35:06 -0800 Received: from HQMAIL108.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Wed, 14 Feb 2018 08:35:41 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Wed, 14 Feb 2018 08:35:41 -0800 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 14 Feb 2018 16:35:01 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server id 15.0.1347.2 via Frontend Transport; Wed, 14 Feb 2018 16:35:01 +0000 Received: from moonraker.nvidia.com (Not Verified[10.21.132.129]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 14 Feb 2018 08:35:00 -0800 From: Jon Hunter To: Mathias Nyman , Greg Kroah-Hartman , Thierry Reding CC: , , , Jon Hunter Subject: [PATCH 1/3] usb: xhci: tegra: Prepare for adding runtime PM support Date: Wed, 14 Feb 2018 16:34:43 +0000 Message-ID: <1518626085-29102-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 --- 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