mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 3/3] dma: let dma_alloc() and dma_zalloc() fail
Date: Fri, 16 Oct 2026 09:36:55 +0200	[thread overview]
Message-ID: <20261016-dma-alloc-v1-3-31fc7afe3954@pengutronix.de> (raw)
In-Reply-To: <20261016-dma-alloc-v1-0-31fc7afe3954@pengutronix.de>

Now that all callers relying on the allocation to always succeed use
dma_xalloc() and dma_xzalloc(), implement dma_alloc() with memalign()
instead of xmemalign(), so it returns NULL on allocation failure like
malloc() does, and the callers checking for NULL get to handle it.

dma_zalloc() is implemented with dma_alloc() and already checks for
NULL, and the !CONFIG_HAS_DMA versions are implemented with malloc()
and calloc() already, so they need no changes.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/dma/map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/map.c b/drivers/dma/map.c
index 806439a05d..7a476ed044 100644
--- a/drivers/dma/map.c
+++ b/drivers/dma/map.c
@@ -5,7 +5,7 @@
 
 void *dma_alloc(size_t size)
 {
-	return xmemalign(DMA_ALIGNMENT, ALIGN(size, DMA_ALIGNMENT));
+	return memalign(DMA_ALIGNMENT, ALIGN(size, DMA_ALIGNMENT));
 }
 EXPORT_SYMBOL(dma_alloc);
 

-- 
2.47.3




  parent reply	other threads:[~2026-10-16  7:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  7:36 [PATCH 0/3] dma: make dma_alloc() and dma_zalloc() fallible Sascha Hauer
2026-10-16  7:36 ` [PATCH 1/3] dma: add dma_xalloc() and dma_xzalloc() Sascha Hauer
2026-10-16 10:31   ` Ahmad Fatoum
2026-10-16  7:36 ` [PATCH 2/3] treewide: use dma_xalloc()/dma_xzalloc() where the result isn't checked Sascha Hauer
2026-10-16 10:35   ` Ahmad Fatoum
2026-10-16  7:36 ` Sascha Hauer [this message]
2026-10-16 10:35   ` [PATCH 3/3] dma: let dma_alloc() and dma_zalloc() fail Ahmad Fatoum

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=20261016-dma-alloc-v1-3-31fc7afe3954@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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