dtc/tests/overlay_overlay_phandle.dts
Uwe Kleine-König 1fad065080 libfdt: overlay: ensure that existing phandles are not overwritten
A phandle in an overlay is not supposed to overwrite a phandle that
already exists in the base dtb as this breaks references to the
respective node in the base.

So add another iteration over the fdto that checks for such overwrites
and fixes the fdto phandle's value to match the fdt's.

A test is added that checks that newly added phandles and existing
phandles work as expected.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Message-ID: <20240225175422.156393-2-u.kleine-koenig@pengutronix.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2024-03-14 20:34:16 +10:00

34 lines
461 B
Text

/*
* Copyright (c) 2024 Uwe Kleine-König
*
* SPDX-License-Identifier: GPL-2.0+
*/
/dts-v1/;
/plugin/;
&{/} {
/*
* /b already has a label "node_b" in the base dts, also b is already
* referenced in the base, so both the base's b and this b have a
* phandle value.
*/
node_b2: b {
value = <42>;
d = <&node_d>;
};
node_c: c {
value = <23>;
b = <&node_b2>;
};
d {
a = <&node_a>;
c = <&node_c>;
};
};
&node_a {
value = <32>;
};