From patchwork Tue Jul 10 21:48:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1179021 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-linux-omap@patchwork.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E7916E003A for ; Tue, 10 Jul 2012 21:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754455Ab2GJVtA (ORCPT ); Tue, 10 Jul 2012 17:49:00 -0400 Received: from na3sys009aog107.obsmtp.com ([74.125.149.197]:43609 "EHLO na3sys009aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754450Ab2GJVs6 (ORCPT ); Tue, 10 Jul 2012 17:48:58 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]) (using TLSv1) by na3sys009aob107.postini.com ([74.125.148.12]) with SMTP ID DSNKT/yjSWP7b01z86M7oDJDh/otl3eDJ4+y@postini.com; Tue, 10 Jul 2012 14:48:57 PDT Received: by pbcwy7 with SMTP id wy7so849804pbc.3 for ; Tue, 10 Jul 2012 14:48:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-gm-message-state; bh=Jcw6M0X4bj34pKBmzMTqLU2/R61mIE0UxZUhoEAUDAg=; b=JCADfKwpk9+BMJcbqjVKqiV+0CH7PwVNV+JUoQt8J/kIBHcUXJrNM/4wi0wqr4dkT8 fPVHUCC32j+4LVdoiaouSPzQ4QFC07oBIkPbzUcLfPxgm2DcM9TWEjycyDFatvOY8Jgr JRvt1nIGPrvwXKf2a6t2pLg23W04Z6yTtuqaXcgq0EFxI5WW/ow4oAzd5W0fsJQlXJ9/ PrbJfpyIUco1YWe0j7/4G/3kZJLDMDQ2Nij2qe6JQ/fSrRb/8cjb/OtvSsAu+Y+IzNKj IcHeiWJz3imJJKBI8emMoiNWfaG3jrMSlqdsRADbrwfdtlp6qnG7PICjR8Ho+BhJBGy3 pIVA== Received: by 10.68.194.234 with SMTP id hz10mr73372704pbc.126.1341956936561; Tue, 10 Jul 2012 14:48:56 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id tj4sm291869pbc.33.2012.07.10.14.48.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 14:48:55 -0700 (PDT) From: Kevin Hilman To: Russell King Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, Chris Ball , linux-mmc@vger.kernel.org Subject: Re: [CFT 03/11] mmc: omap_hsmmc: remove private DMA API implementation Organization: Texas Instruments, Inc. References: <20120607110610.GB15973@n2100.arm.linux.org.uk> Date: Tue, 10 Jul 2012 14:48:56 -0700 In-Reply-To: (Russell King's message of "Thu, 07 Jun 2012 12:07:13 +0100") Message-ID: <87vchvl22f.fsf@ti.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmnfnw/FVOOWZLgzp/FcJfwgHwg8DvMZmOmYs9qM16jpvNB3LygHj6WEHrATeESQaK3WhIS Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Hi Russell, Russell King writes: > Remove the private DMA API implementation from omap_hsmmc, making it > use entirely the DMA engine API. > > Signed-off-by: Russell King While testing this, I noticed a minor problem in the case of probe failure (e.g. if dmaengine is not built into the kernel.) The current driver suffers from this same problem but should probably be fixed when converting to dmaengine... [...] > @@ -2048,36 +1919,28 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) > dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); > goto err_irq; > } > - host->dma_line_tx = res->start; > + tx_req = res->start; > > res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); > if (!res) { > dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); > goto err_irq; > } > - host->dma_line_rx = res->start; > + rx_req = res->start; > > - { > - dma_cap_mask_t mask; > - unsigned sig; > - extern bool omap_dma_filter_fn(struct dma_chan *chan, void *param); > - > - dma_cap_zero(mask); > - dma_cap_set(DMA_SLAVE, mask); > -#if 1 > - sig = host->dma_line_rx; > - host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &sig); > - if (!host->rx_chan) { > - dev_warn(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", sig); > - } > -#endif > -#if 1 > - sig = host->dma_line_tx; > - host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &sig); > - if (!host->tx_chan) { > - dev_warn(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", sig); > - } > -#endif > + dma_cap_zero(mask); > + dma_cap_set(DMA_SLAVE, mask); > + > + host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &rx_req); > + if (!host->rx_chan) { > + dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); > + goto err_irq; > + } > + > + host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &tx_req); > + if (!host->tx_chan) { > + dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); > + goto err_irq; > } If either of these fails, ret is zero so even though this results in a failed probe, the return value (ret) is zero meaning the driver still gets bound to the device. The patch below fixes this and applies on your 'for-next' branch. Or, feel free to fold this into the original if you prefer. Kevin From af7537997b46ee3991985fecd4b4a302bdc0df31 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 10 Jul 2012 14:30:18 -0700 Subject: [PATCH] mmc: omap_hsmmc: ensure probe returns error if DMA channel request fails If dma_request_channel() fails (e.g. because DMA engine is not built into the kernel), the return value from probe is zero causing the driver to be bound to the device even though probe failed. To fix, ensure that probe returns an error value when a DMA channel request fail. Cc: Russell King Signed-off-by: Kevin Hilman --- drivers/mmc/host/omap_hsmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 2338703..ddcecf8 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -1924,12 +1924,14 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &rx_req); if (!host->rx_chan) { dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); + ret = -ENXIO; goto err_irq; } host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &tx_req); if (!host->tx_chan) { dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); + ret -ENXIO; goto err_irq; }