[PATCH] of/address: Add error logging for of_match_bus() in address translation path

From: Zhenhua Huang
Date: Mon Aug 11 2025 - 05:55:15 EST


The change introduced in
commit 045b14ca5c36 ("of: WARN on deprecated #address-cells/#size-cells handling")
triggers a warning on the direct ancestor node when translating properties
like "iommu-addresses"/"reg". However, it fails to issue a warning if the
ancestor’s ancestor is missing the required cells.
For instance, if node_c lacks the necessary properties, no warning will be
generated. Potential issues will be trigger further.
node_c {
//NO WARN
node_b {
//WARN on missing of "address-cells" and "size-cells"
node_a {
xxx = <memory_reion> //contains "iommu-addresses"
}
}
}

Since of_match_bus() is now expected to succeed in traslation path,
routine __of_translate_address. Print an error message would help in
identifying cases where it fails, making such issues easier to diagnose.

Signed-off-by: Zhenhua Huang <quic_zhenhuah@xxxxxxxxxxx>
---
drivers/of/address.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index f0f8f0dd191c..cd33ab64ccf3 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -515,8 +515,10 @@ static u64 __of_translate_address(struct device_node *node,
if (parent == NULL)
return OF_BAD_ADDR;
bus = of_match_bus(parent);
- if (!bus)
+ if (!bus) {
+ pr_err("of_match_bus failed for device node(%pOF)\n", parent);
return OF_BAD_ADDR;
+ }

/* Count address cells & copy address locally */
bus->count_cells(dev, &na, &ns);
@@ -560,8 +562,10 @@ static u64 __of_translate_address(struct device_node *node,

/* Get new parent bus and counts */
pbus = of_match_bus(parent);
- if (!pbus)
+ if (!pbus) {
+ pr_err("of_match_bus failed for device node(%pOF)\n", parent);
return OF_BAD_ADDR;
+ }
pbus->count_cells(dev, &pna, &pns);
if (!OF_CHECK_COUNTS(pna, pns)) {
pr_err("Bad cell count for %pOF\n", dev);
--
2.34.1