All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Viresh Kumar <viresh.linux@gmail.com>,
	Vinod Koul <vinod.koul@intel.com>,
	linux-kernel@vger.kernel.org,
	spear-devel <spear-devel@list.st.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH] dw_dmac: don't exceed AHB master number in dwc_get_data_width
Date: Mon, 14 Jan 2013 16:20:53 +0200	[thread overview]
Message-ID: <1358173253-680-1-git-send-email-andriy.shevchenko@linux.intel.com> (raw)

The driver's default assumes that hardware has two AHB masters which might be
not true. In such rare cases we have not to exceed a number of the AHB masters
present in the hardware. Thus, the AHB master with highest possible number will
be used to retrieve the data witdh value.

The patch also changes the logic a bit when the master parameter of the
dwc_get_data_width() is out of range. Now the function will return a value
related to the first AHB master.

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

diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 30ff2a4..b2d564a 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -80,13 +80,14 @@ static inline unsigned int dwc_get_data_width(struct dma_chan *chan, int master)
 {
 	struct dw_dma *dw = to_dw_dma(chan->device);
 	struct dw_dma_slave *dws = chan->private;
+	unsigned int m = 0;
 
 	if (master == SRC_MASTER)
-		return dw->data_width[dwc_get_sms(dws)];
+		m = dwc_get_sms(dws);
 	else if (master == DST_MASTER)
-		return dw->data_width[dwc_get_dms(dws)];
+		m = dwc_get_dms(dws);
 
-	return 0;
+	return dw->data_width[min_t(unsigned int, dw->nr_masters - 1, m)];
 }
 
 /*----------------------------------------------------------------------*/
-- 
1.7.10.4


             reply	other threads:[~2013-01-14 14:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 14:20 Andy Shevchenko [this message]
2013-01-15  1:54 ` [PATCH] dw_dmac: don't exceed AHB master number in dwc_get_data_width Viresh Kumar
2013-01-15  7:05   ` Andy Shevchenko
2013-01-15  9:01     ` Viresh Kumar
2013-01-15  9:08       ` Andy Shevchenko
2013-01-15  9:09         ` Viresh Kumar
2013-01-15  9:36           ` Andy Shevchenko

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=1358173253-680-1-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 \
    --cc=viresh.linux@gmail.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.