Browse Source

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 14 years ago committed by Jon Loeliger
parent
commit
73ae43ea44
  1. 2
      dtc-lexer.l
  2. 5
      dtc-parser.y
  3. 2
      tests/run_tests.sh
  4. 41
      tests/test_tree1_merge_path.dts

2
dtc-lexer.l

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

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

5
dtc-parser.y

@ -131,13 +131,12 @@ devicetree: @@ -131,13 +131,12 @@ devicetree:
}
| 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)
merge_nodes(target, $3);
else
print_error("label, '%s' not found", $2);
print_error("label or path, '%s', not found", $2);
$$ = $1;
}
;

2
tests/run_tests.sh

@ -305,6 +305,8 @@ dtc_tests () { @@ -305,6 +305,8 @@ dtc_tests () {
run_dtc_test -I dts -O dtb -o multilabel_merge.test.dtb multilabel_merge.dts
run_test references multilabel.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_tests dup-nodename.dts duplicate_node_names

41
tests/test_tree1_merge_path.dts

@ -0,0 +1,41 @@ @@ -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>;
};
Loading…
Cancel
Save