Skip to content

Commit 4b8be38

Browse files
pillo79kartben
authored andcommitted
dtlib: fix 'phandle' property's filename and line number
The phandle property is auto-generated when parsing the DTS, so there is no 'source information'. This commit sets the filename and line number of the phandle property to be the same as the first reference to the target node. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent 90b7c47 commit 4b8be38

File tree

1 file changed

+4
-2
lines changed
  • scripts/dts/python-devicetree/src/devicetree

1 file changed

+4
-2
lines changed

scripts/dts/python-devicetree/src/devicetree/dtlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ def _parse_value_labels(self, prop):
14151415
prop._add_marker(_MarkerType.LABEL, tok.val)
14161416
self._next_token()
14171417

1418-
def _node_phandle(self, node):
1418+
def _node_phandle(self, node, src_prop):
14191419
# Returns the phandle for Node 'node', creating a new phandle if the
14201420
# node has no phandle, and fixing up the value for existing
14211421
# self-referential phandles (which get set to b'\0\0\0\0' initially).
@@ -1435,6 +1435,8 @@ def _node_phandle(self, node):
14351435
phandle_i += 1
14361436
self.phandle2node[phandle_i] = node
14371437

1438+
phandle_prop.filename = src_prop.filename
1439+
phandle_prop.lineno = src_prop.lineno
14381440
phandle_prop.value = phandle_i.to_bytes(4, "big")
14391441
node.props["phandle"] = phandle_prop
14401442

@@ -1878,7 +1880,7 @@ def _fixup_props(self):
18781880
if marker_type is _MarkerType.PATH:
18791881
res += ref_node.path.encode("utf-8") + b'\0'
18801882
else: # marker_type is PHANDLE
1881-
res += self._node_phandle(ref_node)
1883+
res += self._node_phandle(ref_node, prop)
18821884
# Skip over the dummy phandle placeholder
18831885
pos += 4
18841886

0 commit comments

Comments
 (0)