All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bjorn Andersson <andersson@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Stefan Wahren <wahrenst@gmx.net>, Vinod Koul <vkoul@kernel.org>,
	Thomas Andreatta <thomasandreatta2000@gmail.com>,
	Caleb Sander Mateos <csander@purestorage.com>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org
Cc: Olivier Dautricourt <olivierdautricourt@gmail.com>,
	Stefan Roese <sr@denx.de>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
	Daniel Mack <daniel@zonque.org>,
	Haojian Zhuang <haojian.zhuang@gmail.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Lizhi Hou <lizhi.hou@amd.com>, Brian Xu <brian.xu@amd.com>,
	Raj Kumar Rampelli <raj.kumar.rampelli@amd.com>,
	Michal Simek <michal.simek@amd.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v4 11/13] dmaengine: sa11x0: use sg_nents_for_dma() helper
Date: Mon, 24 Nov 2025 13:09:29 +0100	[thread overview]
Message-ID: <20251124121202.424072-12-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20251124121202.424072-1-andriy.shevchenko@linux.intel.com>

Instead of open coded variant let's use recently introduced helper.

Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/dma/sa11x0-dma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index dc1a9a05252e..86f1d7461f56 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -526,7 +526,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
 	struct sa11x0_dma_chan *c = to_sa11x0_dma_chan(chan);
 	struct sa11x0_dma_desc *txd;
 	struct scatterlist *sgent;
-	unsigned i, j = sglen;
+	unsigned int i, j;
 	size_t size = 0;
 
 	/* SA11x0 channels can only operate in their native direction */
@@ -542,10 +542,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
 
 	for_each_sg(sg, sgent, sglen, i) {
 		dma_addr_t addr = sg_dma_address(sgent);
-		unsigned int len = sg_dma_len(sgent);
 
-		if (len > DMA_MAX_SIZE)
-			j += DIV_ROUND_UP(len, DMA_MAX_SIZE & ~DMA_ALIGN) - 1;
 		if (addr & DMA_ALIGN) {
 			dev_dbg(chan->device->dev, "vchan %p: bad buffer alignment: %pad\n",
 				&c->vc, &addr);
@@ -553,6 +550,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
 		}
 	}
 
+	j = sg_nents_for_dma(sg, sglen, DMA_MAX_SIZE & ~DMA_ALIGN);
 	txd = kzalloc(struct_size(txd, sg, j), GFP_ATOMIC);
 	if (!txd) {
 		dev_dbg(chan->device->dev, "vchan %p: kzalloc failed\n", &c->vc);
-- 
2.50.1


  parent reply	other threads:[~2025-11-24 12:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24 12:09 [PATCH v4 0/13] dmaengine: introduce sg_nents_for_dma() and convert users Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 01/13] scatterlist: introduce sg_nents_for_dma() helper Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 02/13] dmaengine: altera-msgdma: use " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 03/13] dmaengine: axi-dmac: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 04/13] dmaengine: bcm2835-dma: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 05/13] dmaengine: dw-axi-dmac: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 06/13] dmaengine: k3dma: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 07/13] dmaengine: lgm: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 08/13] dmaengine: pxa-dma: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 09/13] dmaengine: qcom: adm: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 10/13] dmaengine: qcom: bam_dma: " Andy Shevchenko
2025-11-24 12:09 ` Andy Shevchenko [this message]
2025-11-24 12:09 ` [PATCH v4 12/13] dmaengine: sh: " Andy Shevchenko
2025-11-24 12:09 ` [PATCH v4 13/13] dmaengine: xilinx: xdma: " Andy Shevchenko
2025-12-16 13:11 ` [PATCH v4 0/13] dmaengine: introduce sg_nents_for_dma() and convert users Vinod Koul
2026-01-08  6:46   ` Andy Shevchenko
2026-01-09  2:17     ` Vinod Koul
2026-01-09  3:14 ` Vinod Koul

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=20251124121202.424072-12-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=akpm@linux-foundation.org \
    --cc=andersson@kernel.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brian.xu@amd.com \
    --cc=csander@purestorage.com \
    --cc=daniel@zonque.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=lizhi.hou@amd.com \
    --cc=michal.simek@amd.com \
    --cc=olivierdautricourt@gmail.com \
    --cc=raj.kumar.rampelli@amd.com \
    --cc=rjui@broadcom.com \
    --cc=robert.jarzmik@free.fr \
    --cc=sbranden@broadcom.com \
    --cc=sr@denx.de \
    --cc=thomasandreatta2000@gmail.com \
    --cc=vkoul@kernel.org \
    --cc=wahrenst@gmx.net \
    /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.