diff --git a/scripts/dts/edtlib.py b/scripts/dts/edtlib.py index 1c1830061dd..aeb10e2a76c 100644 --- a/scripts/dts/edtlib.py +++ b/scripts/dts/edtlib.py @@ -1454,10 +1454,11 @@ class Binding: The free-form description of the binding. compatible: - The compatible string the binding matches. This is None if the Binding is - inferred from node properties. If the Binding is a child binding, then - this will be inherited from the parent binding unless the child binding - explicitly sets its own compatible. + The compatible string the binding matches. + + This may be None. For example, it's None when the Binding is inferred + from node properties. It can also be None for Binding objects created + using 'child-binding:' with no compatible. prop2specs: A collections.OrderedDict mapping property names to PropertySpec objects @@ -1564,14 +1565,6 @@ class Binding: if key.endswith("-cells"): self.specifier2cells[key[:-len("-cells")]] = val - # Make child binding compatibles match ours if they are missing. - if self.compatible is not None: - child = self.child_binding - while child is not None: - if child.compatible is None: - child.compatible = self.compatible - child = child.child_binding - def __repr__(self): if self.compatible: compat = f" for compatible '{self.compatible}'" @@ -1587,15 +1580,8 @@ class Binding: @property def compatible(self): "See the class docstring" - if hasattr(self, '_compatible'): - return self._compatible return self.raw.get('compatible') - @compatible.setter - def compatible(self, compatible): - "See the class docstring" - self._compatible = compatible - @property def bus(self): "See the class docstring" diff --git a/scripts/dts/test-bindings/child-binding-with-compat.yaml b/scripts/dts/test-bindings/child-binding-with-compat.yaml index 5a3074b31b8..1744ad2fe76 100644 --- a/scripts/dts/test-bindings/child-binding-with-compat.yaml +++ b/scripts/dts/test-bindings/child-binding-with-compat.yaml @@ -2,7 +2,7 @@ description: child-binding with separate compatible than the parent -compatible: "child-binding-with-compat" +compatible: "top-binding-with-compat" child-binding: compatible: child-compat diff --git a/scripts/dts/test-bindings/child-binding.yaml b/scripts/dts/test-bindings/child-binding.yaml index db4902af82f..5319dea8ac4 100644 --- a/scripts/dts/test-bindings/child-binding.yaml +++ b/scripts/dts/test-bindings/child-binding.yaml @@ -2,7 +2,7 @@ description: child-binding test -compatible: "child-binding" +compatible: "top-binding" child-binding: description: child node diff --git a/scripts/dts/test.dts b/scripts/dts/test.dts index 1b67a191314..0e077fdf627 100644 --- a/scripts/dts/test.dts +++ b/scripts/dts/test.dts @@ -359,7 +359,7 @@ // child-binding { - compatible = "child-binding"; + compatible = "top-binding"; child-1 { child-prop = <1>; grandchild { diff --git a/scripts/dts/testedtlib.py b/scripts/dts/testedtlib.py index c06636accd8..6a180ba873d 100644 --- a/scripts/dts/testedtlib.py +++ b/scripts/dts/testedtlib.py @@ -181,15 +181,15 @@ def test_child_binding(): child = top.child_binding assert Path(top.path) == binding_file assert Path(child.path) == binding_file - assert top.compatible == 'child-binding' - assert child.compatible == 'child-binding' + assert top.compatible == 'top-binding' + assert child.compatible is None binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve() top = edtlib.Binding(binding_file, {}) child = top.child_binding assert Path(top.path) == binding_file assert Path(child.path) == binding_file - assert top.compatible == 'child-binding-with-compat' + assert top.compatible == 'top-binding-with-compat' assert child.compatible == 'child-compat' def test_props():