All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Vinod Koul <vinod.koul@intel.com>,
	spear-devel <spear-devel@list.st.com>,
	linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 2/2] dw_dmac: make usage of dw_dma_slave optional
Date: Thu, 15 Nov 2012 16:20:48 +0200	[thread overview]
Message-ID: <1352989248-28913-2-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1352989248-28913-1-git-send-email-andriy.shevchenko@linux.intel.com>

Currently for the slave transfers the driver requires a custom slave
configuration to be present. Nevertheless, in some cases we need only the
request line as an additional information to the generic slave configuration.
The request line is provided by slave_id parameter of the dma_slave_config
structure. That's why the custom slave configuration could be optional for such
cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/dw_dmac.c |   23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 771aa15..baebf81 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -41,6 +41,11 @@ static inline bool is_slave_direction(enum dma_transfer_direction direction)
 	return (direction == DMA_MEM_TO_DEV) || (direction == DMA_DEV_TO_MEM);
 }
 
+static inline bool dwc_is_slave(struct dma_slave_config *sconfig)
+{
+	return is_slave_direction(sconfig->direction);
+}
+
 static inline unsigned int dwc_get_dms(struct dw_dma_slave *slave)
 {
 	return slave ? slave->dst_master : 0;
@@ -55,11 +60,12 @@ static inline unsigned int dwc_get_sms(struct dw_dma_slave *slave)
 		struct dw_dma_slave *__slave = (_chan->private);	\
 		struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan);	\
 		struct dma_slave_config	*_sconfig = &_dwc->dma_sconfig;	\
+		bool _is_slave = dwc_is_slave(_sconfig);	\
 		int _dms = dwc_get_dms(__slave);		\
 		int _sms = dwc_get_sms(__slave);		\
-		u8 _smsize = __slave ? _sconfig->src_maxburst :	\
+		u8 _smsize = _is_slave ? _sconfig->src_maxburst :	\
 			DW_DMA_MSIZE_16;			\
-		u8 _dmsize = __slave ? _sconfig->dst_maxburst :	\
+		u8 _dmsize = _is_slave ? _sconfig->dst_maxburst :	\
 			DW_DMA_MSIZE_16;			\
 								\
 		(DWC_CTLL_DST_MSIZE(_dmsize)			\
@@ -330,7 +336,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc,
 	list_splice_init(&desc->tx_list, &dwc->free_list);
 	list_move(&desc->desc_node, &dwc->free_list);
 
-	if (!dwc->chan.private) {
+	if (!dwc_is_slave(&dwc->dma_sconfig)) {
 		struct device *parent = chan2parent(&dwc->chan);
 		if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
 			if (txd->flags & DMA_COMPL_DEST_UNMAP_SINGLE)
@@ -809,9 +815,11 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
 
 	dev_vdbg(chan2dev(chan), "%s\n", __func__);
 
-	if (unlikely(!dws || !sg_len))
+	if (unlikely(!is_slave_direction(direction) || !sg_len))
 		return NULL;
 
+	sconfig->direction = direction;
+
 	prev = first = NULL;
 
 	switch (direction) {
@@ -983,8 +991,8 @@ set_runtime_config(struct dma_chan *chan, struct dma_slave_config *sconfig)
 {
 	struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
 
-	/* Check if it is chan is configured for slave transfers */
-	if (!chan->private)
+	/* Check if chan will be configured for slave transfers */
+	if (!dwc_is_slave(sconfig))
 		return -EINVAL;
 
 	memcpy(&dwc->dma_sconfig, sconfig, sizeof(*sconfig));
@@ -1344,6 +1352,8 @@ struct dw_cyclic_desc *dw_dma_cyclic_prep(struct dma_chan *chan,
 	if (unlikely(!is_slave_direction(direction)))
 		goto out_err;
 
+	sconfig->direction = direction;
+
 	if (direction == DMA_MEM_TO_DEV)
 		reg_width = __ffs(sconfig->dst_addr_width);
 	else
@@ -1718,6 +1728,7 @@ static int __devinit dw_probe(struct platform_device *pdev)
 		channel_clear_bit(dw, CH_EN, dwc->mask);
 
 		dwc->dw = dw;
+		dwc->dma_sconfig.direction = DMA_TRANS_NONE;
 
 		/* hardware configuration */
 		if (autocfg) {
-- 
1.7.10.4


  reply	other threads:[~2012-11-15 14:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 14:20 [PATCH 1/2] dw_dmac: check direction properly in dw_dma_cyclic_prep Andy Shevchenko
2012-11-15 14:20 ` Andy Shevchenko [this message]
2012-11-15 14:58   ` [PATCH 2/2] dw_dmac: make usage of dw_dma_slave optional viresh kumar
2012-11-15 15:21     ` Andy Shevchenko
2012-11-15 15:24       ` Viresh Kumar
2012-11-15 15:27         ` Andy Shevchenko
2012-11-15 15:38           ` Viresh Kumar
2012-11-15 17:58             ` Andy Shevchenko
2012-11-16  4:29               ` Viresh Kumar
2012-11-16 12:37                 ` Andy Shevchenko
2012-11-15 14:35 ` [PATCH 1/2] dw_dmac: check direction properly in dw_dma_cyclic_prep viresh kumar
2012-11-15 14:58   ` viresh kumar
2012-11-15 15:17     ` Andy Shevchenko
2012-11-16 12:37   ` Andy Shevchenko
  -- strict thread matches above, loose matches on Subject: below --
2012-11-20 13:38 [PATCH 1/2] dw_dmac: store direction in the custom channel structure Andy Shevchenko
2012-11-20 13:38 ` [PATCH 2/2] dw_dmac: make usage of dw_dma_slave optional Andy Shevchenko
2012-11-20 14:10   ` Viresh Kumar

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=1352989248-28913-2-git-send-email-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spear-devel@list.st.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.