Skip to content

Commit 53e0018

Browse files
committed
ovmerge: Support literal assignments of path strings
The dtc compiler expands &node1 (as opposed to <&node1>) to the full path to the node with the label "node1". Note that if this label is on a node in an overlay that the path will reflect that, even if the node with the label eventually ends up in the base dtb. If a parameter of a base dts is used to make an alias point to another node in the base dts, it is nice to be able to specify that replacement path using a label on that node, rather than have to write it out longhand. Doing so requires one simple change - treating literal assignments of empty strings as a special case: console_uart0 = <&aliases>, "console=", &uart0; Prior to this commit, this would have resulted in an error when the dts file was parsed because the &uart0 path string would have been interpreted as a malformed refence to the next override target. With this commit, the parser sees the empty string assigment and treats the next thing as a string to assign (rather like assigning a phandle value to an integer property). A consequence of this change is that intentionally assigning an empty string (probably a very rare occurence) requires an explicit empty string to be added, i.e. "...=","" or that the empty assignment falls at the end of the list of overrides for that parameter.
1 parent 4e52998 commit 53e0018

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ovmerge/ovmerge

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,19 @@ sub dtparam
721721
my $val = $value;
722722
if ($op eq '=')
723723
{
724-
$val = $opdata;
724+
if ($opdata ne '')
725+
{
726+
$val = $opdata;
727+
}
728+
elsif ($pos == @$ovr)
729+
{
730+
$val = "";
731+
}
732+
else
733+
{
734+
$val = $ovr->[$pos++];
735+
die "* Expected a string or label reference in parameter '$param'\n" if (($val->[0] ne '"') && ($val->[0] ne '&'));
736+
}
725737
}
726738
elsif ($op eq '{')
727739
{
@@ -735,7 +747,7 @@ sub dtparam
735747
}
736748
else
737749
{
738-
apply_prop($node, $prop, ['"', $val]);
750+
apply_prop($node, $prop, ref($val) ? $val : [ '"', $val ]);
739751
}
740752
}
741753
}

0 commit comments

Comments
 (0)