Add merging of labelled subnodes. This patch allows the following

syntax:

/ {
	child {
		label: subchild {
		};
	};
};

&label {
	prop = "value";
};

which will result in the following tree:

/ {
	child {
		label: subchild {
			prop = "value";
		};
	};
};

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This commit is contained in:
David Gibson 2010-09-20 16:33:34 -06:00 committed by Jon Loeliger
parent 390635762d
commit 8773e12fa9
7 changed files with 74 additions and 18 deletions

View file

@ -109,7 +109,7 @@ static int pop_input_file(void);
return DT_LITERAL;
}
\&{LABEL} { /* label reference */
<*>\&{LABEL} { /* label reference */
DPRINT("Ref: %s\n", yytext+1);
yylval.labelref = xstrdup(yytext+1);
return DT_REF;

View file

@ -75,7 +75,6 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
%type <proplist> proplist
%type <node> devicetree
%type <node> devicetrees
%type <node> nodedef
%type <node> subnode
%type <nodelist> subnodes
@ -83,7 +82,7 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
%%
sourcefile:
DT_V1 ';' memreserves devicetrees
DT_V1 ';' memreserves devicetree
{
the_boot_info = build_boot_info($3, $4,
guess_boot_cpuid($4));
@ -120,22 +119,27 @@ addr:
}
;
devicetrees:
devicetree
{
$$ = $1;
}
| devicetrees devicetree
{
$$ = merge_nodes($1, $2);
}
;
devicetree:
'/' nodedef
{
$$ = name_node($2, "");
}
| devicetree '/' nodedef
{
$$ = merge_nodes($1, $3);
}
| devicetree DT_REF nodedef
{
struct node *target;
target = get_node_by_label($1, $2);
if (target)
merge_nodes(target, $3);
else
yyerror("label does not exist in "
" node redefinition");
$$ = $1;
}
;
nodedef:

View file

@ -0,0 +1,10 @@
/dts-v1/;
/ {
label: node {
};
};
/* Try to redefine a node using a non-existent label */
&nosuchnode {
};

View file

@ -300,6 +300,8 @@ dtc_tests () {
# Check merge/overlay functionality
run_dtc_test -I dts -O dtb -o dtc_tree1_merge.test.dtb test_tree1_merge.dts
tree1_tests dtc_tree1_merge.test.dtb test_tree1.dtb
run_dtc_test -I dts -O dtb -o dtc_tree1_merge_labelled.test.dtb test_tree1_merge_labelled.dts
tree1_tests dtc_tree1_merge_labelled.test.dtb test_tree1.dtb
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
@ -312,6 +314,7 @@ dtc_tests () {
check_tests minusone-phandle.dts explicit_phandles
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
run_sh_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
run_sh_test dtc-fatal.sh -I dts -O dtb nonexist-node-ref2.dts
check_tests bad-name-property.dts name_properties
check_tests bad-ncells.dts address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell

View file

@ -25,7 +25,7 @@
linux,phandle = <0x2000>;
prop-int = <123456789>;
subsubnode@0 {
ssn0: subsubnode@0 {
phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;

View file

@ -34,12 +34,10 @@
prop-int = [deadbeef];
};
subnode@2 {
subsubnode@0 {
ssn0: subsubnode@0 {
phandle = <0x2001>;
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
};
};
};

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 {
};
};
};
&ssn0 {
compatible = "subsubnode2", "subsubnode";
prop-int = <0726746425>;
};