linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] DMA: let filter functions of of_dma_simple_xlate possible check of_node
@ 2013-08-02  2:00 Richard Zhao
  2013-08-02 12:06 ` Santosh Shilimkar
  2013-08-22  5:19 ` Richard Zhao
  0 siblings, 2 replies; 14+ messages in thread
From: Richard Zhao @ 2013-08-02  2:00 UTC (permalink / raw)
  To: linux-arm-kernel

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 <rizhao@nvidia.com>
---
 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 <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/of_dma.h>
 
 #include <linux/platform_data/edma.h>
 
@@ -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;
 	}
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-08-28  5:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-02  2:00 [PATCH] DMA: let filter functions of of_dma_simple_xlate possible check of_node Richard Zhao
2013-08-02 12:06 ` Santosh Shilimkar
2013-08-02 20:52   ` Stephen Warren
2013-08-22  5:19 ` Richard Zhao
2013-08-22 20:18   ` Stephen Warren
2013-08-23  1:29     ` Richard Zhao
2013-08-23 15:57       ` Stephen Warren
2013-08-26 12:17         ` Laurent Pinchart
2013-08-26 12:55           ` Richard Zhao
2013-08-26 13:18             ` Laurent Pinchart
2013-08-26 14:10               ` Vinod Koul
2013-08-26 18:15                 ` Arnd Bergmann
2013-08-28  5:37                   ` Vinod Koul
2013-08-26 14:49         ` Richard Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).