summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Richardsen <jonasrichardsen@emlix.com>2024-04-15 14:26:04 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-16 15:38:24 +0200
commit364a1831678d96bcbcd425d8359dc8f32f6a839a (patch)
treec8caa166bcaef5bc3a81560c78bb556cc99f27de
parent65ef5d885263dd9fc61c1d78bd5b951396058d88 (diff)
downloadbarebox-364a1831678d96bcbcd425d8359dc8f32f6a839a.tar.gz
barebox-364a1831678d96bcbcd425d8359dc8f32f6a839a.tar.xz
of: do not copy properties if they already exist in the destination
Currently `of_copy_property` copies the given property even if a property with the same name already exists on the destination node. This leads to kernel warnings about duplicate properties: ``` [ 0.014063] Duplicate name in chosen, renamed to "stdout-path#1" [ 0.014093] Duplicate name in chosen, renamed to "bootargs#1" [ 0.014119] Duplicate name in chosen, renamed to "phandle#1" [ 0.014197] Duplicate name in reserved-memory, renamed to "#address-cells#1" [ 0.014226] Duplicate name in reserved-memory, renamed to "#size-cells#1" [ 0.014252] Duplicate name in reserved-memory, renamed to "ranges#1" [ 0.014278] Duplicate name in reserved-memory, renamed to "phandle#1" ``` Therefore, the function was changed to return an error if the property already exists in the destination. The change does not cause any regressions, because the only usage of this function occurs within `arch/arm/boards/raspberry-pi/rpi-common.c` where the original behaviour of the function is obviously unintended. Signed-off-by: Jonas Richardsen <jonasrichardsen@emlix.com> Link: https://lore.barebox.org/20240415122757.327312-1-jonasrichardsen@emlix.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/of/base.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 9bd0cdaac2..f0d3574148 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2346,6 +2346,9 @@ struct property *of_copy_property(const struct device_node *src,
if (!prop)
return NULL;
+ if (of_property_present(dst, propname))
+ return ERR_PTR(-EEXIST);
+
return of_new_property(dst, propname,
of_property_get_value(prop), prop->length);
}