linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans-Christian Egtvedt <egtvedt@samfundet.no>,
	Haavard Skinnemoen <hskinnemoen@gmail.com>,
	Vinod Koul <vinod.koul@intel.com>,
	Mark Brown <broonie@kernel.org>,
	Hein Tibosch <hein_tibosch@yahoo.es>,
	Russell King <linux@arm.linux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Takashi Iwai <tiwai@suse.de>,
	Kweh Hock Leong <hock.leong.kweh@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Alan Cox <alan@linux.intel.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 05/12] dmaengine: dw: introduce generic filter function
Date: Tue, 19 Aug 2014 20:29:16 +0300	[thread overview]
Message-ID: <1408469363-15901-6-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1408469363-15901-1-git-send-email-andriy.shevchenko@linux.intel.com>

The introduced filter function would be reused in the ACPI and DT cases since
in those cases we have to apply mandatory data to the requested channel. Thus,
patch moves platform driver to use it in that case.

The function unlikely can't be used by users of the driver due to an implicit
dependency to the dw_dmac_core module.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw/core.c     | 20 +++++++++++++++
 drivers/dma/dw/internal.h | 24 +-----------------
 drivers/dma/dw/platform.c | 63 ++++++++++++++---------------------------------
 3 files changed, 40 insertions(+), 67 deletions(-)

diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 1c45212..10e43ea 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -919,6 +919,26 @@ err_desc_get:
 	return NULL;
 }
 
+bool dw_dma_filter(struct dma_chan *chan, void *param)
+{
+	struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
+	struct dw_dma_slave *dws = param;
+
+	if (!dws || dws->dma_dev != chan->device->dev)
+		return false;
+
+	/* We have to copy data since dws can be temporary storage */
+
+	dwc->src_id = dws->src_id;
+	dwc->dst_id = dws->dst_id;
+
+	dwc->src_master = dws->src_master;
+	dwc->dst_master = dws->dst_master;
+
+	return true;
+}
+EXPORT_SYMBOL_GPL(dw_dma_filter);
+
 /*
  * Fix sconfig's burst size according to dw_dmac. We need to convert them as:
  * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
diff --git a/drivers/dma/dw/internal.h b/drivers/dma/dw/internal.h
index 43cc1df..2c8d02f 100644
--- a/drivers/dma/dw/internal.h
+++ b/drivers/dma/dw/internal.h
@@ -43,28 +43,6 @@ int dw_dma_resume(struct dw_dma_chip *chip);
 
 #endif /* CONFIG_PM_SLEEP */
 
-/**
- * dwc_get_dms - get destination master
- * @slave:	pointer to the custom slave configuration
- *
- * Returns destination master in the custom slave configuration if defined, or
- * default value otherwise.
- */
-static inline unsigned int dwc_get_dms(struct dw_dma_slave *slave)
-{
-	return slave ? slave->dst_master : 0;
-}
-
-/**
- * dwc_get_sms - get source master
- * @slave:	pointer to the custom slave configuration
- *
- * Returns source master in the custom slave configuration if defined, or
- * default value otherwise.
- */
-static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
-{
-	return slave ? slave->src_master : 1;
-}
+extern bool dw_dma_filter(struct dma_chan *chan, void *param);
 
 #endif /* _DW_DMAC_INTERNAL_H */
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 7aa3cd3..860c9ac 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -25,74 +25,49 @@
 
 #include "internal.h"
 
-struct dw_dma_of_filter_args {
-	struct dw_dma *dw;
-	unsigned int req;
-	unsigned int src;
-	unsigned int dst;
-};
-
-static bool dw_dma_of_filter(struct dma_chan *chan, void *param)
-{
-	struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
-	struct dw_dma_of_filter_args *fargs = param;
-
-	/* Ensure the device matches our channel */
-	if (chan->device != &fargs->dw->dma)
-		return false;
-
-	dwc->src_id = fargs->req;
-	dwc->dst_id = fargs->req;
-	dwc->src_master	= fargs->src;
-	dwc->dst_master	= fargs->dst;
-
-	return true;
-}
-
 static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec,
 					struct of_dma *ofdma)
 {
 	struct dw_dma *dw = ofdma->of_dma_data;
-	struct dw_dma_of_filter_args fargs = {
-		.dw = dw,
+	struct dw_dma_slave slave = {
+		.dma_dev = dw->dma.dev,
 	};
 	dma_cap_mask_t cap;
 
 	if (dma_spec->args_count != 3)
 		return NULL;
 
-	fargs.req = dma_spec->args[0];
-	fargs.src = dma_spec->args[1];
-	fargs.dst = dma_spec->args[2];
+	slave.src_id = dma_spec->args[0];
+	slave.dst_id = dma_spec->args[0];
+	slave.src_master = dma_spec->args[1];
+	slave.dst_master = dma_spec->args[2];
 
-	if (WARN_ON(fargs.req >= DW_DMA_MAX_NR_REQUESTS ||
-		    fargs.src >= dw->nr_masters ||
-		    fargs.dst >= dw->nr_masters))
+	if (WARN_ON(slave.src_id >= DW_DMA_MAX_NR_REQUESTS ||
+		    slave.dst_id >= DW_DMA_MAX_NR_REQUESTS ||
+		    slave.src_master >= dw->nr_masters ||
+		    slave.dst_master >= dw->nr_masters))
 		return NULL;
 
 	dma_cap_zero(cap);
 	dma_cap_set(DMA_SLAVE, cap);
 
 	/* TODO: there should be a simpler way to do this */
-	return dma_request_channel(cap, dw_dma_of_filter, &fargs);
+	return dma_request_channel(cap, dw_dma_filter, &slave);
 }
 
 #ifdef CONFIG_ACPI
 static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
 {
-	struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
 	struct acpi_dma_spec *dma_spec = param;
+	struct dw_dma_slave slave = {
+		.dma_dev = dma_spec->dev,
+		.src_id = dma_spec->slave_id,
+		.dst_id = dma_spec->slave_id,
+		.src_master = 1,
+		.dst_master = 0,
+	};
 
-	if (chan->device->dev != dma_spec->dev ||
-	    chan->chan_id != dma_spec->chan_id)
-		return false;
-
-	dwc->src_id = dma_spec->slave_id;
-	dwc->dst_id = dma_spec->slave_id;
-	dwc->src_master = dwc_get_sms(NULL);
-	dwc->dst_master = dwc_get_dms(NULL);
-
-	return true;
+	return dw_dma_filter(chan, &slave);
 }
 
 static void dw_dma_acpi_controller_register(struct dw_dma *dw)
-- 
2.1.0


  parent reply	other threads:[~2014-08-19 17:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 17:29 [PATCH v1 00/12] dmaengine: dw: remove slave_id, add PCI support Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 01/12] dmaengine: dw: move dw_dmac.h to where it belongs to Andy Shevchenko
2014-08-20  6:01   ` Hans-Christian Egtvedt
2014-08-20  8:55   ` Viresh Kumar
2014-08-20  8:56     ` Viresh Kumar
2014-08-20  9:28     ` Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 02/12] avr32: at32ap700x: don't rely on default DMA masters Andy Shevchenko
2014-08-20  6:03   ` Hans-Christian Egtvedt
2014-08-19 17:29 ` [PATCH v1 03/12] dmaengine: dw: convert dw_dma_slave to use explicit HS interfaces Andy Shevchenko
2014-08-20  6:15   ` Hans-Christian Egtvedt
2014-08-19 17:29 ` [PATCH v1 04/12] dmaengine: dw: apply both HS interfaces and remove slave_id usage Andy Shevchenko
2014-08-19 17:29 ` Andy Shevchenko [this message]
2014-08-19 17:29 ` [PATCH v1 06/12] dmaengine: dw: move clock operations to platform.c Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 07/12] dmaengine: dw: add PCI IDs for Braswell DMAs Andy Shevchenko
2014-08-19 17:29 ` [PATCH v1 08/12] spi/pxa2xx: Don't use slave_id of dma_slave_config Andy Shevchenko
2014-08-19 21:13   ` Mark Brown
2014-09-11  6:20   ` Vinod Koul
2014-08-19 17:29 ` [PATCH v1 09/12] spi/pxa2xx-pci: remove unnecessary assignment Andy Shevchenko
2014-08-19 21:12   ` Mark Brown
2014-08-19 17:29 ` [PATCH v1 10/12] spi/pxa2xx-pci: Add support for Intel Braswell Andy Shevchenko
2014-08-19 21:14   ` Mark Brown
2014-08-19 17:29 ` [PATCH v1 11/12] serial: 8250: don't use slave_id of dma_slave_config Andy Shevchenko
2014-08-26 22:38   ` Greg Kroah-Hartman
2014-08-19 17:29 ` [PATCH v1 12/12] serial: 8250_pci: Add PCI IDs for Intel Braswell Andy Shevchenko
2014-08-26 22:38   ` Greg Kroah-Hartman
2014-08-20  6:17 ` [PATCH v1 00/12] dmaengine: dw: remove slave_id, add PCI support Hans-Christian Egtvedt
2014-08-27  6:33   ` Andy Shevchenko
2014-08-26 15:27 ` Andy Shevchenko
2014-08-26 22:39   ` Greg Kroah-Hartman
2014-08-27  6:32     ` Andy Shevchenko
2014-08-29 10:00 ` Andy Shevchenko
2014-09-11  6:42 ` Vinod Koul
2014-09-11  7:53   ` Shevchenko, Andriy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408469363-15901-6-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alan@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=egtvedt@samfundet.no \
    --cc=gregkh@linuxfoundation.org \
    --cc=hein_tibosch@yahoo.es \
    --cc=hock.leong.kweh@intel.com \
    --cc=hskinnemoen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mika.westerberg@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).