mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jonas Richardsen <jonasrichardsen@emlix.com>
To: barebox@lists.infradead.org
Cc: Jonas Richardsen <jonasrichardsen@emlix.com>
Subject: [PATCH v2] of: do not copy properties if they already exist in the destination
Date: Mon, 15 Apr 2024 14:26:04 +0200	[thread overview]
Message-ID: <20240415122757.327312-1-jonasrichardsen@emlix.com> (raw)
In-Reply-To: <69c9a97e-80e8-40e9-89c7-b9479f9dfd01@pengutronix.de>

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>
---
In the process of creating this patch, we realized that the fixups 
    for the Raspberry Pi are extensively copying properties from the video
    core device tree that are not strictly necessary. We will do some
    work on making the fixups more precise (i.e., only copy specific
    properties, not entire nodes) soon.

 drivers/of/base.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index b22959dabe..3192a74ab9 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);
 }
-- 
2.42.0




  reply	other threads:[~2024-04-15 12:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10  9:59 raspi: should vc fixups update properties of existing nodes? Jonas Richardsen
2024-04-10 11:51 ` Ahmad Fatoum
2024-04-15  8:14   ` [PATCH] of: do not copy properties if they already exist in the destination Jonas Richardsen
2024-04-15  8:30     ` Ahmad Fatoum
2024-04-15 12:26       ` Jonas Richardsen [this message]
2024-04-16 13:38         ` [PATCH v2] " 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=20240415122757.327312-1-jonasrichardsen@emlix.com \
    --to=jonasrichardsen@emlix.com \
    --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