Skip to content
Permalink
Browse files

edtlib: Check that 'status' has one of the values from the DT spec.

dtlib is meant to be general and anything-goes re. property values, but
edtlib can be pickier. Check that all 'status' properties have one of
the values listed in the devicetree specification
(https://www.devicetree.org/specifications/), and error out otherwise.

This will get rid of the 'status = "ok"'s (should be "okay") that keep
cropping up.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
  • Loading branch information...
ulfalizer authored and galak committed Aug 7, 2019
1 parent 6e5e1e0 commit acf276f1df79462d454ce5f518b07684fccd162c
Showing with 25 additions and 0 deletions.
  1. +25 −0 scripts/dts/edtlib.py
@@ -108,6 +108,7 @@ def __init__(self, dts, bindings_dirs):
self.bindings_dirs = bindings_dirs

self._dt = DT(dts)
_check_dt(self._dt)

self._init_compat2binding(bindings_dirs)
self._init_devices()
@@ -1635,6 +1636,30 @@ def _slice(node, prop_name, size):
return [raw[i:i + size] for i in range(0, len(raw), size)]


def _check_dt(dt):
# Does devicetree sanity checks. dtlib is meant to be general and
# anything-goes except for very special properties like phandle, but in
# edtlib we can be pickier.

# Check that 'status' has one of the values given in the devicetree spec.

ok_status = {"okay", "disabled", "reserved", "fail", "fail-sss"}

for node in dt.node_iter():
if "status" in node.props:
try:
status_val = node.props["status"].to_string()
except DTError as e:
# The error message gives the path
_err(str(e))

if status_val not in ok_status:
_err("unknown 'status' value \"{}\" in {} in {}, expected one "
"of {} (see the devicetree specification)"
.format(status_val, node.path, node.dt.filename,
", ".join(ok_status)))


def _err(msg):
raise EDTError(msg)

0 comments on commit acf276f

Please sign in to comment.
You can’t perform that action at this time.