From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] dma: of_fixups: add fallbacks if /soc doesn't exist
Date: Fri, 3 May 2024 12:29:09 +0200 [thread overview]
Message-ID: <20240503102909.1362544-1-a.fatoum@pengutronix.de> (raw)
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 <a.fatoum@pengutronix.de>
---
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
next reply other threads:[~2024-05-03 10:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 10:29 Ahmad Fatoum [this message]
2024-05-06 6:27 ` 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=20240503102909.1362544-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