From patchwork Sun Nov 9 21:12:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Charkov X-Patchwork-Id: 5261861 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 4BCD6C11AC for ; Sun, 9 Nov 2014 21:17:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55F0220142 for ; Sun, 9 Nov 2014 21:17:24 +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 7773C20127 for ; Sun, 9 Nov 2014 21:17:23 +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 1XnZpK-0002To-Ab; Sun, 09 Nov 2014 21:15:14 +0000 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XnZpH-0001L8-L5 for linux-arm-kernel@lists.infradead.org; Sun, 09 Nov 2014 21:15:12 +0000 Received: by mail-la0-f43.google.com with SMTP id ge10so6820646lab.30 for ; Sun, 09 Nov 2014 13:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=iWXzbl+3PgCq2fsFIWll9YwKbbHiyhPCDsOwHT2jElA=; b=dvPvzcivwNE46gMTuTHDoGqvfRojbgeefvV+DFt8LD6nSLB4P+rI3pOp5rA6lFai7T sti890KYS+XxHoLrdHlk7Dm/nXcH0Ou4mEg7C1ywU1KWcJ/cshy0/Fcmuswp86BW7fch jef20QpP0qUToQlxCqZl3n1WH4b4ZWD+IRcnRbd8kYVVD0wpdEX9IkD7AZ4TE9E4Mpon uA0bsW6+39Ry7AbAIibcjcXMcc6yoOfYdXLI/P6sQVnUtlDuzyd3fzXyBzHSgiDTA7pL mG7AJ1h2h6VFFw0AQtWn6kFjQ3TIze98dNDeV2y+r1wNruJ754UhWMaBny3wYrMp4Hdx 1B8A== X-Received: by 10.152.2.74 with SMTP id 10mr25542741las.22.1415567689234; Sun, 09 Nov 2014 13:14:49 -0800 (PST) Received: from localhost.localdomain (broadband-178-140-2-12.nationalcablenetworks.ru. [178.140.2.12]) by mx.google.com with ESMTPSA id dw2sm4820669lbc.38.2014.11.09.13.14.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 09 Nov 2014 13:14:48 -0800 (PST) From: Alexey Charkov To: Tony Prisk , Chris Ball , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region Date: Mon, 10 Nov 2014 00:12:51 +0300 Message-Id: <1415567571-6144-1-git-send-email-alchark@gmail.com> X-Mailer: git-send-email 2.1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141109_131511_981598_76FE9602 X-CRM114-Status: GOOD ( 16.31 ) X-Spam-Score: -0.8 (/) Cc: Helmut Stengele , Alexey Charkov 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, 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 From: Helmut Stengele 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 (edited commit message) Signed-off-by: Alexey Charkov --- Dear Chris, Ulf, This is a pretty trivial fix to a bug in wmt-sdmmc.c that is only visible upon module unload. Is there any chance to get it merged to the current fixes tree? I think I'd also like to convert other resource requests here to devres, but that would probably be a separate patch to go into -next. That's why we didn't rename the failX: labels, for example (as most of them could be dropped altogether if the respective requesting functions are converted to devres infrastructure). Thanks a lot, Alexey drivers/mmc/host/wmt-sdmmc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c index 54181b4..02b5e6b 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"); @@ -781,6 +782,11 @@ static int wmt_mci_probe(struct platform_device *pdev) goto fail1; } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + ret = -ENODEV; + goto fail1; + } mmc = mmc_alloc_host(sizeof(struct wmt_mci_priv), &pdev->dev); if (!mmc) { dev_err(&pdev->dev, "Failed to allocate mmc_host\n"); @@ -813,7 +819,7 @@ 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); + 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; @@ -826,7 +832,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 +875,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 +885,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); @@ -904,14 +907,9 @@ static int wmt_mci_remove(struct platform_device *pdev) free_irq(priv->irq_regular, priv); free_irq(priv->irq_dma, priv); - iounmap(priv->sdmmc_base); - 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");