The fixup was written for Layerscape LS1046A. Enabling it on i.MX8MP
throws an initcall error, because the SoC node is called /soc@0.
Improve the situation by falling back to either /soc@0 or just plain /.
Signed-off-by: Ahmad Fatoum
---
drivers/dma/of_fixups.c | 33 ++---
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/dma/of_fixups.c b/drivers/dma/of_fixups.c
index 668313bbfb57..084ab94cc71c 100644
--- a/drivers/dma/of_fixups.c
+++ b/drivers/dma/of_fixups.c
@@ -6,15 +6,22 @@
static int of_dma_coherent_fixup(struct device_node *root, void *data)
{
- struct device_node *soc;
- enum dev_dma_coherence coherency = (enum
dev_dma_coherence)(uintptr_t)data;
+ struct device_node *soc_bb = data, *soc_kernel;
+ enum dev_dma_coherence coherency;
- soc = of_find_node_by_path_from(root, "/soc");
- if (!soc)
+ if (of_property_read_bool(soc_bb, "dma-coherent"))
+ coherency = DEV_DMA_COHERENT;
+ else if (of_property_read_bool(soc_bb, "dma-noncoherent"))
+ coherency = DEV_DMA_NON_COHERENT;
+ else
+ coherency = DEV_DMA_COHERENCE_DEFAULT;
+
+ soc_kernel = of_find_node_by_path_from(root, soc_bb->full_name);
+ if (!soc_kernel)
return -ENOENT;
- of_property_write_bool(soc, "dma-noncoherent", coherency ==
DEV_DMA_NON_COHERENT);
- of_property_write_bool(soc, "dma-coherent", coherency ==
DEV_DMA_COHERENT);
+ of_property_write_bool(soc_kernel, "dma-noncoherent", coherency ==
DEV_DMA_NON_COHERENT);
+ of_property_write_bool(soc_kernel, "dma-coherent", coherency ==
DEV_DMA_COHERENT);
return 0;
}
@@ -22,19 +29,15 @@ static int of_dma_coherent_fixup(struct device_node *root,
void *data)
static int of_dma_coherent_fixup_register(void)
{
struct device_node *soc;
- enum dev_dma_coherence soc_dma_coherency;
soc = of_find_node_by_path("/soc");
+ if (!soc)
+ soc = of_find_node_by_path("/soc@0");
+ if (!soc)
+ soc = of_find_node_by_path("/");
if (!soc)
return -ENOENT;
- if (of_property_read_bool(soc, "dma-coherent"))
- soc_dma_coherency = DEV_DMA_COHERENT;
- else if (of_property_read_bool(soc, "dma-noncoherent"))
- soc_dma_coherency = DEV_DMA_NON_COHERENT;
- else
- soc_dma_coherency = DEV_DMA_COHERENCE_DEFAULT;
-
- return of_register_fixup(of_dma_coherent_fixup, (void
*)(uintptr_t)soc_dma_coherency);
+ return of_register_fixup(of_dma_coherent_fixup, soc);
}
coredevice_initcall(of_dma_coherent_fixup_register);
--
2.39.2