Skip to content

Commit f5409de

Browse files
mbolivar-nordicnashif
authored andcommitted
scripts: edtlib: do not inherit parent compatibles
Commit 0d4dca1 ("scripts: edtlib: child binding compatibles match parents") was a hack meant to keep the edtlib.Binding class in place without modifying some twister behavior that needed further changes to work properly with first-class binding objects. This is a hack and is no longer necessary, so back out of this change. Child Binding objects now have None compatible properties unless the binding YAML explicitly sets a compatible. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 963b166 commit f5409de

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

scripts/dts/edtlib.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,10 +1454,11 @@ class Binding:
14541454
The free-form description of the binding.
14551455
14561456
compatible:
1457-
The compatible string the binding matches. This is None if the Binding is
1458-
inferred from node properties. If the Binding is a child binding, then
1459-
this will be inherited from the parent binding unless the child binding
1460-
explicitly sets its own compatible.
1457+
The compatible string the binding matches.
1458+
1459+
This may be None. For example, it's None when the Binding is inferred
1460+
from node properties. It can also be None for Binding objects created
1461+
using 'child-binding:' with no compatible.
14611462
14621463
prop2specs:
14631464
A collections.OrderedDict mapping property names to PropertySpec objects
@@ -1564,14 +1565,6 @@ def __init__(self, path, fname2path, raw=None,
15641565
if key.endswith("-cells"):
15651566
self.specifier2cells[key[:-len("-cells")]] = val
15661567

1567-
# Make child binding compatibles match ours if they are missing.
1568-
if self.compatible is not None:
1569-
child = self.child_binding
1570-
while child is not None:
1571-
if child.compatible is None:
1572-
child.compatible = self.compatible
1573-
child = child.child_binding
1574-
15751568
def __repr__(self):
15761569
if self.compatible:
15771570
compat = f" for compatible '{self.compatible}'"
@@ -1587,15 +1580,8 @@ def description(self):
15871580
@property
15881581
def compatible(self):
15891582
"See the class docstring"
1590-
if hasattr(self, '_compatible'):
1591-
return self._compatible
15921583
return self.raw.get('compatible')
15931584

1594-
@compatible.setter
1595-
def compatible(self, compatible):
1596-
"See the class docstring"
1597-
self._compatible = compatible
1598-
15991585
@property
16001586
def bus(self):
16011587
"See the class docstring"

scripts/dts/test-bindings/child-binding-with-compat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
description: child-binding with separate compatible than the parent
44

5-
compatible: "child-binding-with-compat"
5+
compatible: "top-binding-with-compat"
66

77
child-binding:
88
compatible: child-compat

scripts/dts/test-bindings/child-binding.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
description: child-binding test
44

5-
compatible: "child-binding"
5+
compatible: "top-binding"
66

77
child-binding:
88
description: child node

scripts/dts/test.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@
359359
//
360360

361361
child-binding {
362-
compatible = "child-binding";
362+
compatible = "top-binding";
363363
child-1 {
364364
child-prop = <1>;
365365
grandchild {

scripts/dts/testedtlib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ def test_child_binding():
181181
child = top.child_binding
182182
assert Path(top.path) == binding_file
183183
assert Path(child.path) == binding_file
184-
assert top.compatible == 'child-binding'
185-
assert child.compatible == 'child-binding'
184+
assert top.compatible == 'top-binding'
185+
assert child.compatible is None
186186

187187
binding_file = Path("test-bindings/child-binding-with-compat.yaml").resolve()
188188
top = edtlib.Binding(binding_file, {})
189189
child = top.child_binding
190190
assert Path(top.path) == binding_file
191191
assert Path(child.path) == binding_file
192-
assert top.compatible == 'child-binding-with-compat'
192+
assert top.compatible == 'top-binding-with-compat'
193193
assert child.compatible == 'child-compat'
194194

195195
def test_props():

0 commit comments

Comments
 (0)