From patchwork Wed Apr 20 02:16:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 66162 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2195379qge; Tue, 19 Apr 2016 19:16:59 -0700 (PDT) X-Received: by 10.66.132.37 with SMTP id or5mr8763349pab.144.1461118618978; Tue, 19 Apr 2016 19:16:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si948724pfa.250.2016.04.19.19.16.58; Tue, 19 Apr 2016 19:16:58 -0700 (PDT) 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; dkim=pass header.i=@nifty.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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754523AbcDTCQK (ORCPT + 29 others); Tue, 19 Apr 2016 22:16:10 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:38424 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754304AbcDTCQC (ORCPT ); Tue, 19 Apr 2016 22:16:02 -0400 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id u3K2FZ7l005192; Wed, 20 Apr 2016 11:15:42 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u3K2FZ7l005192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1461118542; bh=KyHA/pDsEFpS6kqeYjUHKz/Ipmj3cDsA2RulWqqX/TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQ9QL37LhsxtSC+/OxrMylNpd97/TWadjvilyiFgDr6Ek+D52j3XiCRR8bT7pATyw 96Vl/4HMoDjbBiFLPdTzC/ZsNxRvMPijUXV8UfvUHYEjCvrk+7qM2vocVLUBiwHevE Vaenf7IGNl+O1p+eSnzzfNQwvUublDnA9NX3Autww9UTJFTtxQAHQ+WDHNPH2yZcXK kcpdZTyzx2NCfFM44Vq0p7l4irjl77u9AguP/FYzIFcacvUYg/AWw83vXsJZlkD4B3 mRs2WRff8vPM2nHLBoibpheZSBGiQ69rvCiT/kvuCdFoJfWlleY2aodBNCjz8ehebr UPynuoYnUcpVQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org, Adrian Hunter , Ulf Hansson Subject: [PATCH v2 7/7] mmc: sdhci-pltfm: call platform_get_irq() before sdhci_alloc_host() Date: Wed, 20 Apr 2016 11:16:31 +0900 Message-Id: <1461118591-21595-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461118591-21595-1-git-send-email-yamada.masahiro@socionext.com> References: <1461118591-21595-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Swap the call order of sdhci_alloc_host() and platform_get_irq(). It makes sdhci_alloc_host() the last function that can fail in the sdhci_pltfm_init(). So, we can drop the sdhci_free_host() call from the failure path. Signed-off-by: Masahiro Yamada --- Changes in v2: None drivers/mmc/host/sdhci-pltfm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index 1d74db8..64f287a 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -120,7 +120,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, struct sdhci_host *host; struct resource *iomem; void __iomem *ioaddr; - int ret; + int irq, ret; iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); ioaddr = devm_ioremap_resource(&pdev->dev, iomem); @@ -129,6 +129,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, goto err; } + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "failed to get IRQ number\n"); + ret = irq; + goto err; + } + host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pltfm_host) + priv_size); @@ -138,6 +145,7 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, } host->ioaddr = ioaddr; + host->irq = irq; host->hw_name = dev_name(&pdev->dev); if (pdata && pdata->ops) host->ops = pdata->ops; @@ -148,13 +156,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, host->quirks2 = pdata->quirks2; } - host->irq = platform_get_irq(pdev, 0); - if (host->irq < 0) { - dev_err(&pdev->dev, "failed to get IRQ number\n"); - ret = host->irq; - goto err_request; - } - /* * Some platforms need to probe the controller to be able to * determine which caps should be used. @@ -165,9 +166,6 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, platform_set_drvdata(pdev, host); return host; - -err_request: - sdhci_free_host(host); err: dev_err(&pdev->dev, "%s failed %d\n", __func__, ret); return ERR_PTR(ret);