From patchwork Tue Feb 3 15:55:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jensen X-Patchwork-Id: 5769901 Return-Path: X-Original-To: patchwork-linux-arm@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 E8BFF9F269 for ; Tue, 3 Feb 2015 15:58:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09EAE201BB for ; Tue, 3 Feb 2015 15:58:27 +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 2C1B220212 for ; Tue, 3 Feb 2015 15:58:26 +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 1YIfq7-0004J7-L6; Tue, 03 Feb 2015 15:56:35 +0000 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YIfq3-00045Y-I0 for linux-arm-kernel@lists.infradead.org; Tue, 03 Feb 2015 15:56:32 +0000 Received: by mail-la0-f53.google.com with SMTP id gq15so53066732lab.12 for ; Tue, 03 Feb 2015 07:56:07 -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:in-reply-to:references; bh=rgyOjtxwi/3zVHn8Xbl8sWWmLQQSNy4kszOZj4wGc0w=; b=WxQzbQOHT6bGvo7ynqCmopDv1WIU1C63GHfg4zdY8C34S6WqqKYpl1so0nUXeqWfWL ICaGQZEpWm+OWL/ZSQoWaEWhdvTJXJe9exJ/Sm9Qvoxhy8ALLqivSCUWOaJ7knE/7DJ2 zsJdxHkT24HMYiid0bSTf2f0VxTgFdiTIuElx6CvX1c883EprqbtWKWaoIWB0uGfk725 KtaeHcOPSwNTxxeKZ+qk1yQ7ZnPLS5AH3F76CcndXEPnkZLD/NuBt8elCjYXXwAeVO98 9p+QYtp8ld4wZcAaVDl2ZVcY1UNrdrJz+QQ7vAnXnX+SV5GMIJYLwL30fWK7DCmvFKGZ H8zA== X-Received: by 10.152.203.230 with SMTP id kt6mr24593554lac.38.1422978967741; Tue, 03 Feb 2015 07:56:07 -0800 (PST) Received: from Ildjarn.ath.cx (static-213-115-41-10.sme.bredbandsbolaget.se. [213.115.41.10]) by mx.google.com with ESMTPSA id te7sm480376lbb.3.2015.02.03.07.56.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 07:56:06 -0800 (PST) From: Jonas Jensen To: linux-mmc@vger.kernel.org Subject: [PATCH v4] mmc: moxart: fix probe logic Date: Tue, 3 Feb 2015 16:55:54 +0100 Message-Id: <1422978954-14547-1-git-send-email-jonas.jensen@gmail.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <6294882.EhDcdWGRYz@wuerfel> References: <6294882.EhDcdWGRYz@wuerfel> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150203_075631_807646_D0517439 X-CRM114-Status: GOOD ( 17.63 ) X-Spam-Score: -0.2 (/) Cc: ulf.hansson@linaro.org, linux@arm.linux.org.uk, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, Jonas Jensen 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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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: Arnd Bergmann Jonas Jensen wanted to submit a patch for these, but apparently forgot about it. I stumbled over this symptom first: drivers/built-in.o: In function `moxart_probe': :(.text+0x2af128): undefined reference to `of_dma_request_slave_channel' This is because of_dma_request_slave_channel is an internal helper and not exported to loadable module. I'm changing the driver to use dma_request_slave_channel_reason() instead. Further problems from inspection: * The remove function must not call kfree on the host pointer, because it is allocated together with the mmc_host. * The clock is never released * The dma_cap_mask_t is completely unused and can be removed * deferred probing does not work if the dma driver is loaded after the mmc driver. This patch should fix all of the above. Signed-off-by: Arnd Bergmann Signed-off-by: Jonas Jensen --- Notes: This is a forward of Arnd's v2 patch. v2: do not call clk_put() on an error pointer v3: fix NULL dereference on host->clk v4: rework to use devm_clk_get() Applies to next-20150113 drivers/mmc/host/moxart-mmc.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c index d2a1ef6..6cb4053 100644 --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -562,7 +563,6 @@ static int moxart_probe(struct platform_device *pdev) struct dma_slave_config cfg; struct clk *clk; void __iomem *reg_mmc; - dma_cap_mask_t mask; int irq, ret; u32 i; @@ -586,9 +586,9 @@ static int moxart_probe(struct platform_device *pdev) goto out; } - clk = of_clk_get(node, 0); + clk = devm_clk_get(dev, 0); if (IS_ERR(clk)) { - dev_err(dev, "of_clk_get failed\n"); + dev_err(dev, "devm_clk_get failed\n"); ret = PTR_ERR(clk); goto out; } @@ -603,9 +603,6 @@ static int moxart_probe(struct platform_device *pdev) if (ret) goto out; - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - host = mmc_priv(mmc); host->mmc = mmc; host->base = reg_mmc; @@ -613,8 +610,8 @@ static int moxart_probe(struct platform_device *pdev) host->timeout = msecs_to_jiffies(1000); host->sysclk = clk_get_rate(clk); host->fifo_width = readl(host->base + REG_FEATURE) << 2; - host->dma_chan_tx = of_dma_request_slave_channel(node, "tx"); - host->dma_chan_rx = of_dma_request_slave_channel(node, "rx"); + host->dma_chan_tx = dma_request_slave_channel_reason(dev, "tx"); + host->dma_chan_rx = dma_request_slave_channel_reason(dev, "rx"); spin_lock_init(&host->lock); @@ -624,6 +621,11 @@ static int moxart_probe(struct platform_device *pdev) mmc->ocr_avail = 0xffff00; /* Support 2.0v - 3.6v power. */ if (IS_ERR(host->dma_chan_tx) || IS_ERR(host->dma_chan_rx)) { + if (PTR_ERR(host->dma_chan_tx) == -EPROBE_DEFER || + PTR_ERR(host->dma_chan_rx) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto out; + } dev_dbg(dev, "PIO mode transfer enabled\n"); host->have_dma = false; } else { @@ -702,9 +704,6 @@ static int moxart_remove(struct platform_device *pdev) writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF, host->base + REG_CLOCK_CONTROL); } - - kfree(host); - return 0; }