From patchwork Fri Jul 15 05:05:56 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: 9231167 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 DEBE960574 for ; Fri, 15 Jul 2016 05:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB6A82819A for ; Fri, 15 Jul 2016 05:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99FA528319; Fri, 15 Jul 2016 05:08:59 +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 06F0C2819A for ; Fri, 15 Jul 2016 05:08:58 +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 1bNvL0-0006tP-B8; Fri, 15 Jul 2016 05:06:58 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bNvKv-0006rd-Gp for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2016 05:06:54 +0000 Received: by mail-lf0-x243.google.com with SMTP id 33so6466292lfw.3 for ; Thu, 14 Jul 2016 22:06:33 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z3kwrT/RrYd0w0OTDtdCJFaqMl8GXZauXc01b6sof6g=; b=SWTu7eSvmoiRUav7vEbx1DM3j3Phw8hMAtFLzPgco1xZB2n9xTa++QxnGI9oAYsNfv d+bgtsW7cKD4Tgb2I5EoJiJIGQD/R70IZeRSw3cRzyC4QorYzf0zp3NsJNNUA2nM9Spk 7Y8LX64KfIMTdM9MUpr9Eb+SCC2BvHUavDw0vDLuDAz9g3AacV9nEresrBU3xwc37q3q 7H+WpgXhG/1V/7NfkKyTUdT91/3LS4SvCOGbIDUyn3XZApxSjXLS1iGbDOCikTCokB3D eC6nzAR+B6mw6L+6yZ90A6xPNbqU66xonRz0AnMA/RHiaSOn9HE1Hj1byD42e8hF74K2 ibvg== 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:mime-version:content-transfer-encoding; bh=Z3kwrT/RrYd0w0OTDtdCJFaqMl8GXZauXc01b6sof6g=; b=mZHEJ9MJrtWA/KTw4cArAyAQRo/KVsAM83EOt15OX4dq66SIR/FXhtqKPtxs5bNaON 52WhAbwkiu3bDXR4cQU1kd5SnL7LuU1TxAiaQPrZN0AJqpQ1mqT+igpe+GuK32gktS6L lFDyw3T0i4Pzi+ZtRSus+zZkMtkAYS3xbVrsXTFir4nfTTNuEnYJCiR+Jygsn1TRwKHe P9TwxZ0z6VlYKR1vxUymHo3576Wzb9KlGq93MY0MYaTYrEHEVaRn55vv96GBSlHmqJgI 8Yyf8xpS3MDJjKQtd4TDdDkQ1dYzA81Rz26JQ9SqUI2ZmVx+9K3D3NQNKEpoG18DBZva G5EQ== X-Gm-Message-State: ALyK8tJgBPPTRxrxUs7g+V6TRyjfwAB4vdbmArmuttIEOykeY17UzXCyTkeQ1H9a2lL3hg== X-Received: by 10.46.32.139 with SMTP id g11mr3659700lji.28.1468559191486; Thu, 14 Jul 2016 22:06:31 -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 192sm1480993ljf.17.2016.07.14.22.06.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 22:06:30 -0700 (PDT) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Greg Kroah-Hartman Subject: [PATCH V2] usb: ehci-platform: use helper variables in probe function Date: Fri, 15 Jul 2016 07:05:56 +0200 Message-Id: <1468559156-17270-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1468398548-5050-1-git-send-email-zajec5@gmail.com> References: <1468398548-5050-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160714_220653_938449_890870F8 X-CRM114-Status: GOOD ( 16.08 ) 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 --- V2: Use 2 extra tabs after line break to match one of already used coding styles. --- 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..d67dd92 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);