[PATCH] fixup! of: populate new device_d::dma_coherent attribute

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Jan 11 08:19:51 PST 2024


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 at multi_v7 CI breakage on next.

Signed-off-by: Ahmad Fatoum <a.fatoum at 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




More information about the barebox mailing list