fdtoverlay: Allow adding labels to __overlay__ nodes in overlays
When applying overlays, we merge symbols from the overlay into the target tree. At the moment the logic for this assumes all symbols in the overlay are attached to a node of the form: /fragment@XXX/__overlay__/relative/path And will end up applied to the relative/path node under the fragment's target. However, this disallows the case of a symbol in the form just: /fragment@XXX/__overlay__ This does have a pretty obvious sensible meaning: attach the new symbol directly to the fragment's target, but we don't currently do that. It's pretty easy to workaround this limitation in one's overlays, but it's also easy to handle in the overlay applying code, so we might as well extend it to cover this case. Reported-by: Christophe Braillon Signed-off-by: David Gibson <david@gibson.dropbear.id.au>main
parent
d6de81b81b
commit
b993534748
|
@ -733,8 +733,6 @@ static int overlay_symbol_update(void *fdt, void *fdto)
|
||||||
/* keep end marker to avoid strlen() */
|
/* keep end marker to avoid strlen() */
|
||||||
e = path + path_len;
|
e = path + path_len;
|
||||||
|
|
||||||
/* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
|
|
||||||
|
|
||||||
if (*path != '/')
|
if (*path != '/')
|
||||||
return -FDT_ERR_BADVALUE;
|
return -FDT_ERR_BADVALUE;
|
||||||
|
|
||||||
|
@ -748,11 +746,18 @@ static int overlay_symbol_update(void *fdt, void *fdto)
|
||||||
|
|
||||||
/* verify format; safe since "s" lies in \0 terminated prop */
|
/* verify format; safe since "s" lies in \0 terminated prop */
|
||||||
len = sizeof("/__overlay__/") - 1;
|
len = sizeof("/__overlay__/") - 1;
|
||||||
if ((e - s) < len || memcmp(s, "/__overlay__/", len))
|
if ((e - s) > len && (memcmp(s, "/__overlay__/", len) == 0)) {
|
||||||
|
/* /<fragment-name>/__overlay__/<relative-subnode-path> */
|
||||||
|
rel_path = s + len;
|
||||||
|
rel_path_len = e - rel_path;
|
||||||
|
} else if ((e - s) == len
|
||||||
|
&& (memcmp(s, "/__overlay__", len - 1) == 0)) {
|
||||||
|
/* /<fragment-name>/__overlay__ */
|
||||||
|
rel_path = "";
|
||||||
|
rel_path_len = 0;
|
||||||
|
} else {
|
||||||
return -FDT_ERR_BADOVERLAY;
|
return -FDT_ERR_BADOVERLAY;
|
||||||
|
}
|
||||||
rel_path = s + len;
|
|
||||||
rel_path_len = e - rel_path;
|
|
||||||
|
|
||||||
/* find the fragment index in which the symbol lies */
|
/* find the fragment index in which the symbol lies */
|
||||||
ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
|
ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
|
||||||
|
|
|
@ -949,6 +949,18 @@ fdtoverlay_tests() {
|
||||||
|
|
||||||
# test that fdtoverlay manages to apply overlays with long target path
|
# test that fdtoverlay manages to apply overlays with long target path
|
||||||
run_fdtoverlay_test lpath "/test-node/sub-test-node/sub-test-node-with-very-long-target-path/test-0" "prop" "-ts" ${basedtb} ${target_long_pathdtb} ${overlay_long_pathdtb}
|
run_fdtoverlay_test lpath "/test-node/sub-test-node/sub-test-node-with-very-long-target-path/test-0" "prop" "-ts" ${basedtb} ${target_long_pathdtb} ${overlay_long_pathdtb}
|
||||||
|
|
||||||
|
# test adding a label to the root of a fragment
|
||||||
|
stacked_base_nolabel=stacked_overlay_base_nolabel.dts
|
||||||
|
stacked_base_nolabeldtb=stacked_overlay_base_nolabel.test.dtb
|
||||||
|
stacked_addlabel=stacked_overlay_addlabel.dts
|
||||||
|
stacked_addlabeldtb=stacked_overlay_addlabel.test.dtb
|
||||||
|
stacked_addlabel_targetdtb=stacked_overlay_target_nolabel.fdtoverlay.test.dtb
|
||||||
|
|
||||||
|
run_dtc_test -@ -I dts -O dtb -o $stacked_base_nolabeldtb $stacked_base_nolabel
|
||||||
|
run_dtc_test -@ -I dts -O dtb -o $stacked_addlabeldtb $stacked_addlabel
|
||||||
|
|
||||||
|
run_fdtoverlay_test baz "/foonode/barnode/baznode" "baz-property" "-ts" ${stacked_base_nolabeldtb} ${stacked_addlabel_targetdtb} ${stacked_addlabeldtb} ${stacked_bardtb} ${stacked_bazdtb}
|
||||||
}
|
}
|
||||||
|
|
||||||
pylibfdt_tests () {
|
pylibfdt_tests () {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
/dts-v1/;
|
||||||
|
/plugin/;
|
||||||
|
/ {
|
||||||
|
fragment@1 {
|
||||||
|
target-path = "/foonode";
|
||||||
|
foo: __overlay__ {
|
||||||
|
overlay-1-property;
|
||||||
|
bar: barnode {
|
||||||
|
bar-property = "bar";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,6 @@
|
||||||
|
/dts-v1/;
|
||||||
|
/ {
|
||||||
|
foonode {
|
||||||
|
foo-property = "foo";
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue