scripts: dts: gen_defines/edtlib: improve encapsulation
Moves node sorting concern into EDT. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This commit is contained in:
parent
945925bd8b
commit
a575c769f8
2 changed files with 19 additions and 19 deletions
|
|
@ -74,25 +74,6 @@ def main():
|
|||
with open(args.dts_out, "w", encoding="utf-8") as f:
|
||||
print(edt.dts_source, file=f)
|
||||
|
||||
# The raw index into edt.compat2nodes[compat] is used for node
|
||||
# instance numbering within a compatible.
|
||||
#
|
||||
# As a way to satisfy people's intuitions about instance numbers,
|
||||
# though, we sort this list so enabled instances come first.
|
||||
#
|
||||
# This might look like a hack, but it keeps drivers and
|
||||
# applications which don't use instance numbers carefully working
|
||||
# as expected, since e.g. instance number 0 is always the
|
||||
# singleton instance if there's just one enabled node of a
|
||||
# particular compatible.
|
||||
#
|
||||
# This doesn't violate any devicetree.h API guarantees about
|
||||
# instance ordering, since we make no promises that instance
|
||||
# numbers are stable across builds.
|
||||
for compat, nodes in edt.compat2nodes.items():
|
||||
edt.compat2nodes[compat] = sorted(
|
||||
nodes, key=lambda node: 0 if node.status == "okay" else 1)
|
||||
|
||||
# Create the generated header.
|
||||
with open(args.header_out, "w", encoding="utf-8") as header_file:
|
||||
write_top_comment(edt)
|
||||
|
|
|
|||
|
|
@ -2400,6 +2400,25 @@ class EDT:
|
|||
f"node '{node.path}' compatible '{compat}' "
|
||||
f"has unknown vendor prefix '{vendor}'")
|
||||
|
||||
# The raw index into edt.compat2nodes[compat] is used for node
|
||||
# instance numbering within a compatible.
|
||||
#
|
||||
# As a way to satisfy people's intuitions about instance numbers,
|
||||
# we sort this list so enabled instances come first.
|
||||
#
|
||||
# This might look like a hack, but it keeps drivers and
|
||||
# applications which don't use instance numbers carefully working
|
||||
# as expected, since e.g. instance number 0 is always the
|
||||
# singleton instance if there's just one enabled node of a
|
||||
# particular compatible.
|
||||
#
|
||||
# This doesn't violate any devicetree.h API guarantees about
|
||||
# instance ordering, since we make no promises that instance
|
||||
# numbers are stable across builds.
|
||||
for compat, nodes in self.compat2nodes.items():
|
||||
self.compat2nodes[compat] = sorted(
|
||||
nodes, key=lambda node: 0 if node.status == "okay" else 1
|
||||
)
|
||||
|
||||
for nodeset in self.scc_order:
|
||||
node = nodeset[0]
|
||||
|
|
|
|||
Loading…
Reference in a new issue