From patchwork Wed Jul 13 08:29:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 9227087 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 6952D6086B for ; Wed, 13 Jul 2016 08:31:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59BB1272AA for ; Wed, 13 Jul 2016 08:31:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EA2E27D85; Wed, 13 Jul 2016 08:31:13 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham 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 B1AF0272AA for ; Wed, 13 Jul 2016 08:31:12 +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 1bNFYG-0002iX-7O; Wed, 13 Jul 2016 08:29:52 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bNFYC-0002Y3-Ku for linux-arm-kernel@lists.infradead.org; Wed, 13 Jul 2016 08:29:49 +0000 Received: by mail-lf0-x244.google.com with SMTP id l89so3240612lfi.2 for ; Wed, 13 Jul 2016 01:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1G7P9mf4fo4dvYmD2zRQXz3Dx26P0U5jXeU0WkWLA3g=; b=FRLyG8OCcnGI9KcRsDZXFKN/ARtvxg3fz7ei8VX2DVt0dzSqBlqrhdJWGqofEODgTt 1zxn1lqEchDnNgGFMeyO72fp8MgfzFQZxvLagMTVhvZH7XtzrqnNFmf8kiNKpVhHz7SP sOLm0V7h0O8DOunQZdOK26D23Ve6/YBdcxBVtuXU+z6r8P3CDv0i6H9M9WYYbIdnkTDx tdmqvQIn7olnQdJIvKnWXH/8oXG2JQbE5gQIU/r3vbFvNWQfXmiO3GZljhI11MQHsuJi +ODfA0SkLiiV77IhvUxQfrLQZqXeB3vIB9nR3mUzWBqwD8MkA/kdczNRroiDofp3ynd2 njlg== 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:mime-version :content-transfer-encoding; bh=1G7P9mf4fo4dvYmD2zRQXz3Dx26P0U5jXeU0WkWLA3g=; b=LkF9VxMDFn5qCxO0Em6u+bvewjoQXF0zjWo1PAvlXaR7/wk7CxMC1hU9zXykOyZnQg pShIG89ZOZKqyNKsoVDNR55oYuWeUxj7csPla1/E0P7mdhSg4ZXkQTmdKSWrE3GxdtC5 W5dgOQFkuqnM2wp8KpzVrgQoMBtqblJX0cMf+R9iu+/E2UoF0gfYzDP/VxlMVhIHPb6W noXS/LtPw/Bql+p4UAD/Vp6/tLQz11lXJ0sLxDpiSuJsD3QPN7bZvxL6XrmrFCA6wBSJ +q2yCdLMQYnF1mMAHC6TU8FQWY2Kc9Uq319XCW3swYorNVQBgnVD+NtkNbOLqSW590Ay O+1g== X-Gm-Message-State: ALyK8tIbAW8anc2zLv5RjuD/dK37lV/ORJPp9HqVJrNNH6ZJZjwB5GDFuvzJg+uqnsDbfg== X-Received: by 10.25.43.144 with SMTP id r138mr3968631lfr.112.1468398566164; Wed, 13 Jul 2016 01:29:26 -0700 (PDT) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id k15sm199944lfb.25.2016.07.13.01.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jul 2016 01:29:25 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Greg Kroah-Hartman Subject: [PATCH] usb: ehci-platform: use helper variables in probe function Date: Wed, 13 Jul 2016 10:29:08 +0200 Message-Id: <1468398548-5050-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160713_012949_070312_87987A1B X-CRM114-Status: GOOD ( 15.47 ) 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: "open list:USB EHCI DRIVER" , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , open list , Tony Prisk , Alan Stern , "moderated list:ARM/VT8500 ARM ARCHITECTURE" 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 Probing function was using &dev->dev and dev->dev.of_node over 20 times so I believe it made sense to use helper variables for both of them. To avoid some uncommon variable name for struct device I first replaced existing dev variable with pdev. Signed-off-by: Rafał Miłecki Acked-by: Alan Stern --- drivers/usb/host/ehci-platform.c | 65 +++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 6816b8c..c5cf4e2 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -143,11 +143,13 @@ static struct usb_ehci_pdata ehci_platform_defaults = { .power_off = ehci_platform_power_off, }; -static int ehci_platform_probe(struct platform_device *dev) +static int ehci_platform_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct usb_hcd *hcd; struct resource *res_mem; - struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); + struct usb_ehci_pdata *pdata = dev_get_platdata(dev); struct ehci_platform_priv *priv; struct ehci_hcd *ehci; int err, irq, phy_num, clk = 0, rst; @@ -162,52 +164,49 @@ static int ehci_platform_probe(struct platform_device *dev) if (!pdata) pdata = &ehci_platform_defaults; - err = dma_coerce_mask_and_coherent(&dev->dev, + err = dma_coerce_mask_and_coherent(dev, pdata->dma_mask_64 ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32)); if (err) { - dev_err(&dev->dev, "Error: DMA mask configuration failed\n"); + dev_err(dev, "Error: DMA mask configuration failed\n"); return err; } - irq = platform_get_irq(dev, 0); + irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&dev->dev, "no irq provided"); + dev_err(dev, "no irq provided"); return irq; } - hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, - dev_name(&dev->dev)); + hcd = usb_create_hcd(&ehci_platform_hc_driver, dev, dev_name(dev)); if (!hcd) return -ENOMEM; - platform_set_drvdata(dev, hcd); - dev->dev.platform_data = pdata; + platform_set_drvdata(pdev, hcd); + dev->platform_data = pdata; priv = hcd_to_ehci_priv(hcd); ehci = hcd_to_ehci(hcd); - if (pdata == &ehci_platform_defaults && dev->dev.of_node) { - if (of_property_read_bool(dev->dev.of_node, "big-endian-regs")) + if (pdata == &ehci_platform_defaults && np) { + if (of_property_read_bool(np, "big-endian-regs")) ehci->big_endian_mmio = 1; - if (of_property_read_bool(dev->dev.of_node, "big-endian-desc")) + if (of_property_read_bool(np, "big-endian-desc")) ehci->big_endian_desc = 1; - if (of_property_read_bool(dev->dev.of_node, "big-endian")) + if (of_property_read_bool(np, "big-endian")) ehci->big_endian_mmio = ehci->big_endian_desc = 1; - if (of_property_read_bool(dev->dev.of_node, - "needs-reset-on-resume")) + if (of_property_read_bool(np, "needs-reset-on-resume")) priv->reset_on_resume = true; - if (of_property_read_bool(dev->dev.of_node, - "has-transaction-translator")) + if (of_property_read_bool(np, "has-transaction-translator")) hcd->has_tt = 1; - priv->num_phys = of_count_phandle_with_args(dev->dev.of_node, - "phys", "#phy-cells"); + priv->num_phys = of_count_phandle_with_args(np, "phys", + "#phy-cells"); if (priv->num_phys > 0) { - priv->phys = devm_kcalloc(&dev->dev, priv->num_phys, + priv->phys = devm_kcalloc(dev, priv->num_phys, sizeof(struct phy *), GFP_KERNEL); if (!priv->phys) return -ENOMEM; @@ -216,7 +215,7 @@ static int ehci_platform_probe(struct platform_device *dev) for (phy_num = 0; phy_num < priv->num_phys; phy_num++) { priv->phys[phy_num] = devm_of_phy_get_by_index( - &dev->dev, dev->dev.of_node, phy_num); + dev, np, phy_num); if (IS_ERR(priv->phys[phy_num])) { err = PTR_ERR(priv->phys[phy_num]); goto err_put_hcd; @@ -224,7 +223,7 @@ static int ehci_platform_probe(struct platform_device *dev) } for (clk = 0; clk < EHCI_MAX_CLKS; clk++) { - priv->clks[clk] = of_clk_get(dev->dev.of_node, clk); + priv->clks[clk] = of_clk_get(np, clk); if (IS_ERR(priv->clks[clk])) { err = PTR_ERR(priv->clks[clk]); if (err == -EPROBE_DEFER) @@ -237,7 +236,7 @@ static int ehci_platform_probe(struct platform_device *dev) for (rst = 0; rst < EHCI_MAX_RSTS; rst++) { priv->rsts[rst] = devm_reset_control_get_shared_by_index( - &dev->dev, rst); + dev, rst); if (IS_ERR(priv->rsts[rst])) { err = PTR_ERR(priv->rsts[rst]); if (err == -EPROBE_DEFER) @@ -262,29 +261,27 @@ static int ehci_platform_probe(struct platform_device *dev) #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO if (ehci->big_endian_mmio) { - dev_err(&dev->dev, - "Error: CONFIG_USB_EHCI_BIG_ENDIAN_MMIO not set\n"); + dev_err(dev, "Error: CONFIG_USB_EHCI_BIG_ENDIAN_MMIO not set\n"); err = -EINVAL; goto err_reset; } #endif #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_DESC if (ehci->big_endian_desc) { - dev_err(&dev->dev, - "Error: CONFIG_USB_EHCI_BIG_ENDIAN_DESC not set\n"); + dev_err(dev, "Error: CONFIG_USB_EHCI_BIG_ENDIAN_DESC not set\n"); err = -EINVAL; goto err_reset; } #endif if (pdata->power_on) { - err = pdata->power_on(dev); + err = pdata->power_on(pdev); if (err < 0) goto err_reset; } - res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); - hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + hcd->regs = devm_ioremap_resource(dev, res_mem); if (IS_ERR(hcd->regs)) { err = PTR_ERR(hcd->regs); goto err_power; @@ -297,13 +294,13 @@ static int ehci_platform_probe(struct platform_device *dev) goto err_power; device_wakeup_enable(hcd->self.controller); - platform_set_drvdata(dev, hcd); + platform_set_drvdata(pdev, hcd); return err; err_power: if (pdata->power_off) - pdata->power_off(dev); + pdata->power_off(pdev); err_reset: while (--rst >= 0) reset_control_assert(priv->rsts[rst]); @@ -312,7 +309,7 @@ err_put_clks: clk_put(priv->clks[clk]); err_put_hcd: if (pdata == &ehci_platform_defaults) - dev->dev.platform_data = NULL; + dev->platform_data = NULL; usb_put_hcd(hcd);