Skip to content

Commit

Permalink
scripts: edtlib: Call nodes "nodes" instead of "devices"
Browse files Browse the repository at this point in the history
edtlib.Device is just a devicetree node augmented with binding
information and some interpretation of properties. Rename it to
edtlib.Node to make that clearer. That also avoids calling things like
flash partition nodes "devices", which is a bit confusing.

I called it edtlib.Device instead of edtlib.Node originally to avoid
confusion with dtlib.Node, but in retrospect it probably makes it more
confusing on the whole. Something like edtlib.ENode might work too, but
it's probably overkill. Clients of edtlib.py only interact with
edtlib.Node, so the only potential for confusion is within edtlib.py
itself, and it doesn't get too bad there either.

Piggyback some documentation nits, and consistently write it
"devicetree" instead of "device tree", to match the spec.

Signed-off-by: Ulf Magnusson <[email protected]>
  • Loading branch information
ulfalizer authored and galak committed Sep 26, 2019
1 parent 51f550c commit 73ac146
Show file tree
Hide file tree
Showing 5 changed files with 420 additions and 417 deletions.
27 changes: 15 additions & 12 deletions scripts/dts/dtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# pylint: disable=undefined-variable

"""
A library for extracting information from .dts (Device Tree) files. See the
A library for extracting information from .dts (devicetree) files. See the
documentation for the DT and Node classes for more information.
The top-level entry point of the library is the DT class. DT.__init__() takes a
Expand All @@ -23,14 +23,17 @@
import sys
import textwrap

# NOTE: testdtlib.py is the test suite for this library. It can be run directly.
# NOTE: testdtlib.py is the test suite for this library. It can be run directly
# as a script:
#
# ./testdtlib.py


class DT:
"""
Represents a device tree parsed from a .dts file (or from many files, if
the .dts file /include/s other files). Creating many instances of this
class is fine. The library has no global state.
Represents a devicetree parsed from a .dts file (or from many files, if the
.dts file /include/s other files). Creating many instances of this class is
fine. The library has no global state.
These attributes are available on DT instances:
Expand Down Expand Up @@ -160,7 +163,7 @@ def has_node(self, path):

def node_iter(self):
"""
Returns a generator for iterating over all nodes in the device tree.
Returns a generator for iterating over all nodes in the devicetree.
For example, this will print the name of each node that has a property
called 'foo':
Expand All @@ -173,8 +176,8 @@ def node_iter(self):

def __str__(self):
"""
Returns a DTS representation of the device tree. Called automatically
if the DT instance is print()ed.
Returns a DTS representation of the devicetree. Called automatically if
the DT instance is print()ed.
"""
s = "/dts-v1/;\n\n"

Expand Down Expand Up @@ -1165,7 +1168,7 @@ def _open(self, filename, mode="r", **kwargs):

class Node:
r"""
Represents a node in the device tree ('node-name { ... };').
Represents a node in the devicetree ('node-name { ... };').
These attributes are available on Node instances:
Expand Down Expand Up @@ -1721,7 +1724,7 @@ def _add_marker(self, marker_type, data=None):
def to_num(data, length=None, signed=False):
"""
Converts the 'bytes' array 'data' to a number. The value is expected to be
in big-endian format, which is standard in Device Tree.
in big-endian format, which is standard in devicetree.
length (default: None):
The expected length of the value in bytes, as a simple type check. If
Expand All @@ -1743,7 +1746,7 @@ def to_num(data, length=None, signed=False):
def to_nums(data, length=4, signed=False):
"""
Like Property.to_nums(), but takes an arbitrary 'bytes' array. The values
are assumed to be in big-endian format, which is standard in Device Tree.
are assumed to be in big-endian format, which is standard in devicetree.
"""
_check_is_bytes(data)
_check_length_positive(length)
Expand Down Expand Up @@ -1844,7 +1847,7 @@ def _err(msg):


class DTError(Exception):
"Exception raised for Device Tree-related errors"
"Exception raised for devicetree-related errors"


_Token = collections.namedtuple("Token", "id val")
Expand Down
Loading

0 comments on commit 73ac146

Please sign in to comment.