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: 8885241 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D31869F39A for ; Wed, 20 Apr 2016 02:17:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 136E82015E for ; Wed, 20 Apr 2016 02:17:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 232502025A for ; Wed, 20 Apr 2016 02:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbcDTCQI (ORCPT ); Tue, 19 Apr 2016 22:16:08 -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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);