scripts: edtlib: Turn Node.description into a @property

Simplifies the code a bit.

Looks like the description wasn't rstrip()ed when it came from a
'child-binding:' either. This also indirectly fixes that.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
Ulf Magnusson 2019-10-14 17:30:22 +02:00 committed by Carles Cufí
parent 047969c0d0
commit 72bfa83670

View file

@ -548,6 +548,10 @@ class Node:
translated through any 'ranges' properties on parent nodes, or None if
the node name has no unit-address portion
description:
The description string from the binding for the node, or None if the node
has no binding. Trailing whitespace (including newlines) is removed.
path:
The devicetree path of the node
@ -583,10 +587,6 @@ class Node:
The 'compatible' string for the binding that matched the node, or None if
the node has no binding
description:
The description string from the binding file for the node, or None if the
node has no binding. Trailing whitespace (including newlines) is removed.
binding_path:
The path to the binding file for the node, or None if the node has no
binding
@ -645,6 +645,13 @@ class Node:
return addr
@property
def description(self):
"See the class docstring."
if self._binding and "description" in self._binding:
return self._binding["description"].rstrip()
return None
@property
def path(self):
"See the class docstring"
@ -742,10 +749,6 @@ class Node:
self._binding, self.binding_path = \
self.edt._compat2binding[compat, bus]
self.description = self._binding.get("description")
if self.description:
self.description = self.description.rstrip()
return
else:
# No 'compatible' property. See if the parent binding has a
@ -759,13 +762,11 @@ class Node:
self._binding = binding_from_parent
self.binding_path = self.parent.binding_path
self.matching_compat = self.parent.matching_compat
self.description = self._binding["description"]
return
# No binding found
self._binding = self.binding_path = self.matching_compat = \
self.description = None
self._binding = self.binding_path = self.matching_compat = None
def _binding_from_parent(self):
# Returns the binding from 'child-binding:' in the parent node's