mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] fixup! of: populate new device_d::dma_coherent attribute
Date: Thu, 11 Jan 2024 17:19:51 +0100	[thread overview]
Message-ID: <20240111161951.2276057-1-a.fatoum@pengutronix.de> (raw)

dev may be NULL, e.g. when

  dma_sync_single_for_cpu(NULL,

is called. Such instances are broken anyway, but we still have them,
e.g. in Raspberry Pi code for mailbox, so add a NULL check.

Fixes qemu-rpi0@multi_v7 CI breakage on next.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/driver.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index c23404ca16fb..43d002f66dbe 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -730,13 +730,15 @@ static inline struct device_node *dev_of_node(struct device *dev)
 
 static inline bool dev_is_dma_coherent(struct device *dev)
 {
-	switch (dev->dma_coherent) {
-	case DEV_DMA_NON_COHERENT:
-		return false;
-	case DEV_DMA_COHERENT:
-		return true;
-	case DEV_DMA_COHERENCE_DEFAULT:
-		break;
+	if (dev) {
+		switch (dev->dma_coherent) {
+		case DEV_DMA_NON_COHERENT:
+			return false;
+		case DEV_DMA_COHERENT:
+			return true;
+		case DEV_DMA_COHERENCE_DEFAULT:
+			break;
+		}
 	}
 
 	return IS_ENABLED(CONFIG_ARCH_DMA_DEFAULT_COHERENT);
-- 
2.39.2




             reply	other threads:[~2024-01-11 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 16:19 Ahmad Fatoum [this message]
2024-01-11 17:54 ` (subset) " Sascha Hauer

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=20240111161951.2276057-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@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