Allow nodes to be referenced by path at the top level.

When nodes are modified by merging device trees, nodes to be updated/merged can
be specified by a label. Specifying nodes by full path (instead of label)
doesn't quite work. This patch fixes that.

Signed-off-by: John Bonesio <bones@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
main
John Bonesio 2010-11-02 15:55:04 -07:00 committed by Jon Loeliger
parent c0fa2e6d4e
commit 73ae43ea44
4 changed files with 46 additions and 4 deletions

View File

@ -115,7 +115,7 @@ static int pop_input_file(void);
return DT_REF; return DT_REF;
} }


"&{/"{PATHCHAR}+\} { /* new-style path reference */ <*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
yytext[yyleng-1] = '\0'; yytext[yyleng-1] = '\0';
DPRINT("Ref: %s\n", yytext+2); DPRINT("Ref: %s\n", yytext+2);
yylval.labelref = xstrdup(yytext+2); yylval.labelref = xstrdup(yytext+2);

View File

@ -131,13 +131,12 @@ devicetree:
} }
| devicetree DT_REF nodedef | devicetree DT_REF nodedef
{ {
struct node *target; struct node *target = get_node_by_ref($1, $2);


target = get_node_by_label($1, $2);
if (target) if (target)
merge_nodes(target, $3); merge_nodes(target, $3);
else else
print_error("label, '%s' not found", $2); print_error("label or path, '%s', not found", $2);
$$ = $1; $$ = $1;
} }
; ;

View File

@ -305,6 +305,8 @@ dtc_tests () {
run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb multilabel_merge.dts run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb multilabel_merge.dts
run_test references multilabel.test.dtb run_test references multilabel.test.dtb
run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb run_test dtbs_equal_ordered multilabel.test.dtb multilabel_merge.test.dtb
run_dtc_test -I dts -O dtb -o dtc_tree1_merge_path.test.dtb test_tree1_merge_path.dts
tree1_tests dtc_tree1_merge_path.test.dtb test_tree1.dtb


# Check some checks # Check some checks
check_tests dup-nodename.dts duplicate_node_names check_tests dup-nodename.dts duplicate_node_names

View File

@ -0,0 +1,41 @@
/dts-v1/;

/memreserve/ 0xdeadbeef00000000 0x100000;
/memreserve/ 123456789 010000;

/ {
compatible = "test_tree1";
prop-int = <0xdeadbeef>;
prop-str = "hello world";

subnode@1 {
compatible = "subnode1";
prop-int = [deadbeef];

subsubnode {
compatible = "subsubnode1", "subsubnode";
prop-int = <0xdeadbeef>;
};

ss1 {
};
};

subnode@2 {
linux,phandle = <0x2000>;
prop-int = <123456789>;

ssn0: subsubnode@0 {
phandle = <0x2001>;
prop-int = <0xbad>;
};

ss2 {
};
};
};

&{/subnode@2/subsubnode@0} {
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
};