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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux