From patchwork Mon Nov 7 20:39:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Haslam X-Patchwork-Id: 9416039 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 6D3776022E for ; Mon, 7 Nov 2016 20:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EEFB28D24 for ; Mon, 7 Nov 2016 20:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52BA328E03; Mon, 7 Nov 2016 20:42:37 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD1EB28D24 for ; Mon, 7 Nov 2016 20:42:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3qj5-0001Ov-M3; Mon, 07 Nov 2016 20:41:07 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3qib-0001IV-1t for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2016 20:40:39 +0000 Received: by mail-wm0-x232.google.com with SMTP id a197so206628861wmd.0 for ; Mon, 07 Nov 2016 12:40:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5sSEF9WzGAncMFnqf5dUCOLgLTk/HzGppNkbS31+6tI=; b=d5PR13l+5EfJEn2KBgabjadPYJYxAsHhWUKnqFPJ+Ab8kYDJbLuKRYfFjS3SiVZ2Wa nLGkMDe+pQl8bYpl4+GJ6hixpBxH8x6HVlnBZSLbpZ9fs+e9T4cAjcOB7vnmIZjhT6Rh mUhFdVX1+SeUuEH+WBcGOG828IexqlbmyRDRCK+a2EobjMFAEzNwV1GhTV/3RynHAJtV eCs2UTQLoYLWUDoIIG8WfR/Ag7GMJWDNZixZRh1jWMbzhTxcXcOQxmnBSRhZTuSsxex1 Yr1Jubsd1Y0RKaDNIuWMot/9tQ9JbnAz8HJcBj6uAY0f45tTyfpML8O5dJQhSLQZrJLP 5Rig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5sSEF9WzGAncMFnqf5dUCOLgLTk/HzGppNkbS31+6tI=; b=LzH78fEg8cu7yRrm/u6CE7SZ5MKjEZp/XwNpC51hF7fOLNCKHmoAh+qV8EGEeQ+2Nl AWiv+tEowD/gWdFMjX1Mx7XxICQu5k9jjdnNUog8mn6Qvz4k3g9WGniYTQK+O8cdNrUk fS8fjeoYk2he7NgSmGmi/ZfFkeb09sSFqpk1pC91zJ8/1CRfgWDagel99n/nzTZoAwsT tQ1gDmcuIf1O91tyxq33ZMcO++TbPDFkjRjOT8x0lOqeitIjaGX9a3ff2ZSCeC4CUqfo 1rnpr+Yr0NLnVHbrAoIYq3hpF4o/hUGtx5aw7pCdKEwHhmJEjoWad7tYPzZYY4zIf3S6 7cAA== X-Gm-Message-State: ABUngvc5O6JiEcOs0Ok26xU4BKKhdEE0wkpI77qSru9VlQrun3or/jf/x0cA/DMBpKWT3J2i X-Received: by 10.28.131.72 with SMTP id f69mr8428194wmd.33.1478551216134; Mon, 07 Nov 2016 12:40:16 -0800 (PST) Received: from localhost.localdomain (ANice-652-1-139-209.w83-201.abo.wanadoo.fr. [83.201.210.209]) by smtp.gmail.com with ESMTPSA id r7sm19626644wjp.43.2016.11.07.12.40.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Nov 2016 12:40:15 -0800 (PST) From: Axel Haslam To: stern@rowland.harvard.edu, gregkh@linuxfoundation.org, nsekhar@ti.com, khilman@kernel.org, david@lechnology.com, robh+dt@kernel.org Subject: [PATCH v3 01/10] USB: ohci: da8xx: use ohci priv data instead of globals Date: Mon, 7 Nov 2016 21:39:39 +0100 Message-Id: <20161107203948.28324-2-ahaslam@baylibre.com> X-Mailer: git-send-email 2.10.1.502.g6598894 In-Reply-To: <20161107203948.28324-1-ahaslam@baylibre.com> References: <20161107203948.28324-1-ahaslam@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161107_124037_335483_07E54708 X-CRM114-Status: GOOD ( 15.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Axel Haslam , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of global variables, use the extra_priv_size of the ohci driver. We cannot yet move the ocic mask because this is used on the interrupt handler which is registerded through platform data and does not have an hcd pointer. This will be moved on a later patch. Signed-off-by: Axel Haslam --- drivers/usb/host/ohci-da8xx.c | 72 +++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index 429d58b..0442c64 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -35,43 +35,49 @@ static int (*orig_ohci_hub_control)(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength); static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf); -static struct clk *usb11_clk; -static struct phy *usb11_phy; +struct da8xx_ohci_hcd { + struct clk *usb11_clk; + struct phy *usb11_phy; +}; +#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv) /* Over-current indicator change bitmask */ static volatile u16 ocic_mask; -static int ohci_da8xx_enable(void) +static int ohci_da8xx_enable(struct usb_hcd *hcd) { + struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); int ret; - ret = clk_prepare_enable(usb11_clk); + ret = clk_prepare_enable(da8xx_ohci->usb11_clk); if (ret) return ret; - ret = phy_init(usb11_phy); + ret = phy_init(da8xx_ohci->usb11_phy); if (ret) goto err_phy_init; - ret = phy_power_on(usb11_phy); + ret = phy_power_on(da8xx_ohci->usb11_phy); if (ret) goto err_phy_power_on; return 0; err_phy_power_on: - phy_exit(usb11_phy); + phy_exit(da8xx_ohci->usb11_phy); err_phy_init: - clk_disable_unprepare(usb11_clk); + clk_disable_unprepare(da8xx_ohci->usb11_clk); return ret; } -static void ohci_da8xx_disable(void) +static void ohci_da8xx_disable(struct usb_hcd *hcd) { - phy_power_off(usb11_phy); - phy_exit(usb11_phy); - clk_disable_unprepare(usb11_clk); + struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); + + phy_power_off(da8xx_ohci->usb11_phy); + phy_exit(da8xx_ohci->usb11_phy); + clk_disable_unprepare(da8xx_ohci->usb11_clk); } /* @@ -97,7 +103,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd) dev_dbg(dev, "starting USB controller\n"); - result = ohci_da8xx_enable(); + result = ohci_da8xx_enable(hcd); if (result < 0) return result; @@ -109,7 +115,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd) result = ohci_setup(hcd); if (result < 0) { - ohci_da8xx_disable(); + ohci_da8xx_disable(hcd); return result; } @@ -231,6 +237,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, static int ohci_da8xx_probe(struct platform_device *pdev) { struct da8xx_ohci_root_hub *hub = dev_get_platdata(&pdev->dev); + struct da8xx_ohci_hcd *da8xx_ohci; struct usb_hcd *hcd; struct resource *mem; int error, irq; @@ -238,25 +245,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev) if (hub == NULL) return -ENODEV; - usb11_clk = devm_clk_get(&pdev->dev, "usb11"); - if (IS_ERR(usb11_clk)) { - if (PTR_ERR(usb11_clk) != -EPROBE_DEFER) + hcd = usb_create_hcd(&ohci_da8xx_hc_driver, &pdev->dev, + dev_name(&pdev->dev)); + if (!hcd) + return -ENOMEM; + + da8xx_ohci = to_da8xx_ohci(hcd); + + da8xx_ohci->usb11_clk = devm_clk_get(&pdev->dev, "usb11"); + if (IS_ERR(da8xx_ohci->usb11_clk)) { + if (PTR_ERR(da8xx_ohci->usb11_clk) != -EPROBE_DEFER) dev_err(&pdev->dev, "Failed to get clock.\n"); - return PTR_ERR(usb11_clk); + error = PTR_ERR(da8xx_ohci->usb11_clk); + goto err; } - usb11_phy = devm_phy_get(&pdev->dev, "usb-phy"); - if (IS_ERR(usb11_phy)) { - if (PTR_ERR(usb11_phy) != -EPROBE_DEFER) + da8xx_ohci->usb11_phy = devm_phy_get(&pdev->dev, "usb-phy"); + if (IS_ERR(da8xx_ohci->usb11_phy)) { + if (PTR_ERR(da8xx_ohci->usb11_phy) != -EPROBE_DEFER) dev_err(&pdev->dev, "Failed to get phy.\n"); - return PTR_ERR(usb11_phy); + error = PTR_ERR(da8xx_ohci->usb11_phy); + goto err; } - hcd = usb_create_hcd(&ohci_da8xx_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!hcd) - return -ENOMEM; - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); hcd->regs = devm_ioremap_resource(&pdev->dev, mem); if (IS_ERR(hcd->regs)) { @@ -321,7 +332,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev, if (ret) return ret; - ohci_da8xx_disable(); + ohci_da8xx_disable(hcd); hcd->state = HC_STATE_SUSPENDED; return ret; @@ -337,7 +348,7 @@ static int ohci_da8xx_resume(struct platform_device *dev) msleep(5); ohci->next_statechange = jiffies; - ret = ohci_da8xx_enable(); + ret = ohci_da8xx_enable(hcd); if (ret) return ret; @@ -349,7 +360,8 @@ static int ohci_da8xx_resume(struct platform_device *dev) #endif static const struct ohci_driver_overrides da8xx_overrides __initconst = { - .reset = ohci_da8xx_reset, + .reset = ohci_da8xx_reset, + .extra_priv_size = sizeof(struct da8xx_ohci_hcd), }; /*