From patchwork Thu Apr 14 02:29:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 8830501 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 7DFAE9F3A0 for ; Thu, 14 Apr 2016 02:29:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88C2420274 for ; Thu, 14 Apr 2016 02:29:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A19E52017E for ; Thu, 14 Apr 2016 02:29:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753565AbcDNC3a (ORCPT ); Wed, 13 Apr 2016 22:29:30 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:40503 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbcDNC33 (ORCPT ); Wed, 13 Apr 2016 22:29:29 -0400 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id u3E2Sr3i010961; Thu, 14 Apr 2016 11:28:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u3E2Sr3i010961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1460600940; bh=NyWU7m06+KieeCjTv+gaRoP44oS2iNJuK/eI21zcKbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMdf+H3spzI+s6cq5lyuNaz5LF+hAzX4XO3Pv7jMafQqA3fiQu9h/AOKoA0x2wkmF 1kOnAE/aYU2EC0psoUJviXg0sNUe97m/MxKZuXnmfH6+J2WPRjku1kUf54vqsExlzN lsFI57XvofFHNE7v4B/Flc9Uj5sDuD/7DrIGkX6GhBRLjTqCPBWlXKGeBb2Lme3jpC PIrNUVLRwanpeaPdO2vFK/pHN7pYvYU87EiGQAyENfJXh9MDia+mg5JONSsKsIYZiw OxseMpnI0npykV6OTLbMeZl+aFjaKSHGsb8J5K8iQXIi+ZqjMcFiWMXhDPiUANBvqg okmgiNZb9rLmQ== 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 7/7] mmc: sdhci-pltfm: call platform_get_irq() before sdhci_alloc_host() Date: Thu, 14 Apr 2016 11:29:50 +0900 Message-Id: <1460600990-10993-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460600990-10993-1-git-send-email-yamada.masahiro@socionext.com> References: <1460600990-10993-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=ham 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 this probe method. So, we can drop the sdhci_free_host() call from the failure path. Signed-off-by: Masahiro Yamada --- 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 870c3d7..94bdca8 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); @@ -135,6 +135,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"); + ret = irq; + goto err; + } + host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pltfm_host) + priv_size); @@ -144,6 +151,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; @@ -154,13 +162,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"); - ret = host->irq; - goto err_request; - } - /* * Some platforms need to probe the controller to be able to * determine which caps should be used. @@ -171,9 +172,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);