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>
This commit is contained in:
parent
6e5e1e028d
commit
acf276f1df
1 changed files with 25 additions and 0 deletions
|
@ -108,6 +108,7 @@ class EDT:
|
||||||
self.bindings_dirs = bindings_dirs
|
self.bindings_dirs = bindings_dirs
|
||||||
|
|
||||||
self._dt = DT(dts)
|
self._dt = DT(dts)
|
||||||
|
_check_dt(self._dt)
|
||||||
|
|
||||||
self._init_compat2binding(bindings_dirs)
|
self._init_compat2binding(bindings_dirs)
|
||||||
self._init_devices()
|
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)]
|
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):
|
def _err(msg):
|
||||||
raise EDTError(msg)
|
raise EDTError(msg)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue