From patchwork Thu Nov 20 14:45:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lautriv X-Patchwork-Id: 5348641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43A51C11AC for ; Thu, 20 Nov 2014 14:58:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6EE28201EF for ; Thu, 20 Nov 2014 14:58:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8798B201ED for ; Thu, 20 Nov 2014 14:58:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XrT9g-0007kA-0W; Thu, 20 Nov 2014 14:56:20 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XrT9e-0007jz-0v for linux-arm-kernel@bombadil.infradead.org; Thu, 20 Nov 2014 14:56:18 +0000 Received: from coldplug.net ([109.75.184.172] helo=external.coldplug.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XrT9b-0000LF-DN for linux-arm-kernel@lists.infradead.org; Thu, 20 Nov 2014 14:56:16 +0000 Received: from localhost (localhost [127.0.0.1]) by external.coldplug.net (Postfix) with ESMTP id 375063A543 for ; Thu, 20 Nov 2014 15:45:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=coldplug.net; h= content-transfer-encoding:content-type:content-type:in-reply-to :references:subject:subject:to:mime-version:user-agent:from:from :date:date:message-id; s=dkim; t=1416494705; x=1417358705; bh=s8 pGIbJsgFtvD1YSysphXIKZHOHGs2fs3mWhe5wqIwo=; b=BtmsYB+HpDlNH+81FD tR3JjLlkeqVdT0+h+lO9h6qxNL1FyzF4l7LEthINDzDtXiRGViKZdfMqzuEVx9yb P/aytyHNRFqyX8XVQ+GTlj8aMZ1+gDQ8LRMMK+ElGmgFLHqb5aNnWPAnCU1NzR84 cnThQdft2D55L1Po+9WnIriWs= X-Virus-Scanned: Debian amavisd-new at MYHOSTNAME Received: from external.coldplug.net ([127.0.0.1]) by localhost (external.coldplug.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GfWcWOZqVszC for ; Thu, 20 Nov 2014 15:45:05 +0100 (CET) Received: from [10.0.0.248] (f050082016.adsl.alicedsl.de [78.50.82.16]) by external.coldplug.net (Postfix) with ESMTPSA id 56A473A34E; Thu, 20 Nov 2014 15:44:42 +0100 (CET) Message-ID: <546DFE83.8060900@coldplug.net> Date: Thu, 20 Nov 2014 15:45:23 +0100 From: lautriv User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Alexey Charkov Subject: Re: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region References: <1415567571-6144-1-git-send-email-alchark@gmail.com> <545FE821.5060107@coldplug.net> In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141120_095615_649248_6520B6DD X-CRM114-Status: GOOD ( 15.98 ) X-Spam-Score: -1.8 (-) Cc: Ulf Hansson , "linux-mmc@vger.kernel.org" , Chris Ball , linux-kernel , Tony Prisk , Fabio Estevam , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 From b0509e27e33326e6dccd67d8ebe67e2bdb0cfdde Mon Sep 17 00:00:00 2001 From: Helmut Stengele Date: Thu, 20 Nov 2014 15:27:40 +0100 Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region Current code calls release_mem_region upon module unload without requesting the region first. This patch fixes it by moving to a devres-based ioremap implementation, which handles requesting and releasing memory region internally. This also makes the error/unload paths a bit simpler. Signed-off-by: Helmut Stengele --- This is a corrected patch based on the one Alexey sent for me. I sent it already but since i'm not used to send something upstream it was an attached file and obviously rejected. Patch is tested on bare-metal ( wm8850 ) and works like suspected. drivers/mmc/host/wmt-sdmmc.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c index 54181b4..bcaa0cc 100644 --- a/drivers/mmc/host/wmt-sdmmc.c +++ b/drivers/mmc/host/wmt-sdmmc.c @@ -759,6 +759,7 @@ static int wmt_mci_probe(struct platform_device *pdev) const struct wmt_mci_caps *wmt_caps; int ret; int regular_irq, dma_irq; + struct resource *res; if (!of_id || !of_id->data) { dev_err(&pdev->dev, "Controller capabilities data missing\n"); @@ -813,10 +814,11 @@ static int wmt_mci_probe(struct platform_device *pdev) if (of_get_property(np, "cd-inverted", NULL)) priv->cd_inverted = 1; - priv->sdmmc_base = of_iomap(np, 0); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + priv->sdmmc_base = devm_ioremap_resource(&pdev->dev, res); if (!priv->sdmmc_base) { dev_err(&pdev->dev, "Failed to map IO space\n"); - ret = -ENOMEM; + ret = PTR_ERR(priv->sdmmc_base); goto fail2; } @@ -826,7 +828,7 @@ static int wmt_mci_probe(struct platform_device *pdev) ret = request_irq(regular_irq, wmt_mci_regular_isr, 0, "sdmmc", priv); if (ret) { dev_err(&pdev->dev, "Register regular IRQ fail\n"); - goto fail3; + goto fail2; } ret = request_irq(dma_irq, wmt_mci_dma_isr, 0, "sdmmc", priv); @@ -869,8 +871,6 @@ fail5: free_irq(dma_irq, priv); fail4: free_irq(regular_irq, priv); -fail3: - iounmap(priv->sdmmc_base); fail2: mmc_free_host(mmc); fail1: @@ -881,7 +881,6 @@ static int wmt_mci_remove(struct platform_device *pdev) { struct mmc_host *mmc; struct wmt_mci_priv *priv; - struct resource *res; u32 reg_tmp; mmc = platform_get_drvdata(pdev); @@ -909,9 +908,6 @@ static int wmt_mci_remove(struct platform_device *pdev) clk_disable_unprepare(priv->clk_sdmmc); clk_put(priv->clk_sdmmc); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - release_mem_region(res->start, resource_size(res)); - mmc_free_host(mmc); dev_info(&pdev->dev, "WMT MCI device removed\n");