Skip to content

Commit 2dca9f4

Browse files
mbolivar-nordicgalak
authored andcommitted
dts: edtlib: fix child bindings which have compatibles
Whenever a child-binding: dict has a compatible, we ought to make that available in EDT._compat2binding. If we don't, we can't look it up later. This has adverse effects like missing child bindings which describe buses. Fixes: zephyrproject-rtos#32071 Signed-off-by: Martí Bolívar <[email protected]>
1 parent 1804d7f commit 2dca9f4

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

scripts/dts/edtlib.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -344,26 +344,12 @@ def _init_compat2binding(self):
344344
# if necessary.
345345
binding = self._binding(raw, binding_path, dt_compats)
346346

347-
if binding is None:
348-
# Either the file is not a binding or it's a binding
349-
# whose compatible does not appear in the devicetree
350-
# (picked up via some unrelated text in the binding
351-
# file that happened to match a compatible).
352-
continue
353-
354-
# Do not allow two different bindings to have the same
355-
# 'compatible:'/'on-bus:' combo
356-
old_binding = self._compat2binding.get((binding.compatible,
357-
binding.on_bus))
358-
if old_binding:
359-
msg = (f"both {old_binding.path} and {binding_path} have "
360-
f"'compatible: {binding.compatible}'")
361-
if binding.on_bus is not None:
362-
msg += f" and 'on-bus: {binding.on_bus}'"
363-
_err(msg)
364-
365-
# Register the binding.
366-
self._compat2binding[binding.compatible, binding.on_bus] = binding
347+
# Register the binding in self._compat2binding, along with
348+
# any child bindings that have their own compatibles.
349+
while binding is not None:
350+
if binding.compatible:
351+
self._register_binding(binding)
352+
binding = binding.child_binding
367353

368354
def _binding(self, raw, binding_path, dt_compats):
369355
# Convert a 'raw' binding from YAML to a Binding object and return it.
@@ -387,6 +373,21 @@ def _binding(self, raw, binding_path, dt_compats):
387373
# Initialize and return the Binding object.
388374
return Binding(binding_path, self._binding_fname2path, raw=raw)
389375

376+
def _register_binding(self, binding):
377+
# Do not allow two different bindings to have the same
378+
# 'compatible:'/'on-bus:' combo
379+
old_binding = self._compat2binding.get((binding.compatible,
380+
binding.on_bus))
381+
if old_binding:
382+
msg = (f"both {old_binding.path} and {binding.path} have "
383+
f"'compatible: {binding.compatible}'")
384+
if binding.on_bus is not None:
385+
msg += f" and 'on-bus: {binding.on_bus}'"
386+
_err(msg)
387+
388+
# Register the binding.
389+
self._compat2binding[binding.compatible, binding.on_bus] = binding
390+
390391
def _init_nodes(self):
391392
# Creates a list of edtlib.Node objects from the dtlib.Node objects, in
392393
# self.nodes

0 commit comments

Comments
 (0)