From patchwork Fri Aug 2 02:00:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 2837473 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 0065EBF535 for ; Fri, 2 Aug 2013 02:00:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 265A620320 for ; Fri, 2 Aug 2013 02:00:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D17320315 for ; Fri, 2 Aug 2013 02:00:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V54fS-0002hF-DB; Fri, 02 Aug 2013 02:00:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V54fM-0002Zz-BF; Fri, 02 Aug 2013 02:00:28 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V54fK-0002YQ-4s for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 02:00:26 +0000 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Thu, 01 Aug 2013 18:59:54 -0700 Received: from hqemhub01.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Thu, 01 Aug 2013 18:58:30 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Thu, 01 Aug 2013 18:58:30 -0700 Received: from hkemhub02.nvidia.com (10.18.67.13) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.298.1; Thu, 1 Aug 2013 18:59:59 -0700 Received: from rizhao-lap.nvidia.com (10.18.67.5) by hkemhub02.nvidia.com (10.18.67.13) with Microsoft SMTP Server (TLS) id 8.3.298.1; Fri, 2 Aug 2013 09:59:40 +0800 From: Richard Zhao To: , , Subject: [PATCH] DMA: let filter functions of of_dma_simple_xlate possible check of_node Date: Fri, 2 Aug 2013 10:00:00 +0800 Message-ID: <1375408800-11789-1-git-send-email-rizhao@nvidia.com> X-Mailer: git-send-email 1.8.1.5 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130801_220026_312945_0E9274F5 X-CRM114-Status: GOOD ( 14.69 ) X-Spam-Score: -3.4 (---) Cc: vinod.koul@intel.com, swarren@wwwdotorg.org, Richard Zhao , djbw@fb.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 pass of_phandle_args dma_spec to dma_request_channel in of_dma_simple_xlate, so the filter function could access of_node in of_phandle_args. It also remove restriction of #dma-cells has to be one. Signed-off-by: Richard Zhao --- drivers/dma/edma.c | 7 +++++-- drivers/dma/of-dma.c | 10 ++++------ drivers/dma/omap-dma.c | 6 ++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 4f6d87b..54582fd 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -604,9 +605,11 @@ static struct platform_driver edma_driver = { bool edma_filter_fn(struct dma_chan *chan, void *param) { - if (chan->device->dev->driver == &edma_driver.driver) { + struct of_phandle_args *dma_spec = param; + if (chan->device->dev->driver == &edma_driver.driver && + dma_spec->np == chan->device->dev->of_node) { struct edma_chan *echan = to_edma_chan(chan); - unsigned ch_req = *(unsigned *)param; + unsigned ch_req = dma_spec->args[0]; return ch_req == echan->ch_num; } return false; diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 75334bd..e1c4d3b 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -192,11 +192,9 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, * @dma_spec: pointer to DMA specifier as found in the device tree * @of_dma: pointer to DMA controller data * - * A simple translation function for devices that use a 32-bit value for the + * A simple translation function for devices that use dma_spec for the * filter_param when calling the DMA engine dma_request_channel() function. - * Note that this translation function requires that #dma-cells is equal to 1 - * and the argument of the dma specifier is the 32-bit filter_param. Returns - * pointer to appropriate dma channel on success or NULL on error. + * Returns pointer to appropriate dma channel on success or NULL on error. */ struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) @@ -207,10 +205,10 @@ struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec, if (!info || !info->filter_fn) return NULL; - if (count != 1) + if (count < 1) return NULL; return dma_request_channel(info->dma_cap, info->filter_fn, - &dma_spec->args[0]); + dma_spec); } EXPORT_SYMBOL_GPL(of_dma_simple_xlate); diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c index ec3fc4f..32547ec 100644 --- a/drivers/dma/omap-dma.c +++ b/drivers/dma/omap-dma.c @@ -693,9 +693,11 @@ static struct platform_driver omap_dma_driver = { bool omap_dma_filter_fn(struct dma_chan *chan, void *param) { - if (chan->device->dev->driver == &omap_dma_driver.driver) { + struct of_phandle_args *dma_spec = param; + if (chan->device->dev->driver == &omap_dma_driver.driver && + dma_spec->np == chan->device->dev->of_node) { struct omap_chan *c = to_omap_dma_chan(chan); - unsigned req = *(unsigned *)param; + unsigned req = dma_spec->args[0]; return req == c->dma_sig; }