From patchwork Tue May 13 15:44:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 4169201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5E131C0ACC for ; Tue, 13 May 2014 15:48:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D28320353 for ; Tue, 13 May 2014 15:48:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4E5E20373 for ; Tue, 13 May 2014 15:48:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkEtn-0005JG-5n; Tue, 13 May 2014 15:45:47 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkEtT-0004cN-7U for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 15:45:28 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 038EE857; Tue, 13 May 2014 17:45:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 4EE2779A; Tue, 13 May 2014 17:45:05 +0200 (CEST) From: Maxime Ripard To: Emilio Lopez , Mike Turquette , stern@rowland.harvard.edu, kishon@ti.com, hdegoede@redhat.com, Greg Kroah-Hartman Subject: [PATCH RESEND v4 3/8] phy: sunxi: Rework phy initialization Date: Tue, 13 May 2014 17:44:17 +0200 Message-Id: <1399995862-17788-4-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1399995862-17788-1-git-send-email-maxime.ripard@free-electrons.com> References: <1399995862-17788-1-git-send-email-maxime.ripard@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_084527_632792_EB2874E6 X-CRM114-Status: GOOD ( 14.42 ) X-Spam-Score: 0.3 (/) Cc: linux-sunxi@googlegroups.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, zhuzhenhua@allwinnertech.com, Boris Brezillon , kevin.z.m.zh@gmail.com, sunny@allwinnertech.com, shuge@allwinnertech.com, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Move the phy initialization and variables declaration to the loop itself, since it is where it really belongs. Also remove all the temporary variables, we can use the structure members directly. Signed-off-by: Maxime Ripard Reviewed-by: Hans de Goede --- drivers/phy/phy-sun4i-usb.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index e6e6c4ba7145..66a87d50512b 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -224,13 +224,8 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) struct sun4i_usb_phy_data *data; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - void __iomem *pmu = NULL; struct phy_provider *phy_provider; - struct reset_control *reset; - struct regulator *vbus; struct resource *res; - struct phy *phy; - char name[16]; int i; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -262,42 +257,41 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) /* Skip 0, 0 is the phy for otg which is not yet supported. */ for (i = 1; i < data->num_phys; i++) { + struct sun4i_usb_phy *phy = data->phys + i; + char name[16]; + snprintf(name, sizeof(name), "usb%d_vbus", i); - vbus = devm_regulator_get_optional(dev, name); - if (IS_ERR(vbus)) { - if (PTR_ERR(vbus) == -EPROBE_DEFER) + phy->vbus = devm_regulator_get_optional(dev, name); + if (IS_ERR(phy->vbus)) { + if (PTR_ERR(phy->vbus) == -EPROBE_DEFER) return -EPROBE_DEFER; - vbus = NULL; + phy->vbus = NULL; } snprintf(name, sizeof(name), "usb%d_reset", i); - reset = devm_reset_control_get(dev, name); - if (IS_ERR(reset)) { + phy->reset = devm_reset_control_get(dev, name); + if (IS_ERR(phy->reset)) { dev_err(dev, "failed to get reset %s\n", name); - return PTR_ERR(reset); + return PTR_ERR(phy->reset); } if (i) { /* No pmu for usbc0 */ snprintf(name, sizeof(name), "pmu%d", i); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); - pmu = devm_ioremap_resource(dev, res); - if (IS_ERR(pmu)) - return PTR_ERR(pmu); + phy->pmu = devm_ioremap_resource(dev, res); + if (IS_ERR(phy->pmu)) + return PTR_ERR(phy->pmu); } - phy = devm_phy_create(dev, &sun4i_usb_phy_ops, NULL); - if (IS_ERR(phy)) { + phy->phy = devm_phy_create(dev, &sun4i_usb_phy_ops, NULL); + if (IS_ERR(phy->phy)) { dev_err(dev, "failed to create PHY %d\n", i); - return PTR_ERR(phy); + return PTR_ERR(phy->phy); } - data->phys[i].phy = phy; - data->phys[i].pmu = pmu; - data->phys[i].vbus = vbus; - data->phys[i].reset = reset; - data->phys[i].index = i; - phy_set_drvdata(phy, &data->phys[i]); + phy->index = i; + phy_set_drvdata(phy->phy, &data->phys[i]); } dev_set_drvdata(dev, data);