Skip to content
Browse files

scripts: dts: support multiple binding dirs in new scripts and were recently added in
commit 62d5741 ("dts: Add new DTS/binding parser").

The old script allowed for multiple
dts bindings dirs.  Let's add that functionality to the new
scripts as well.

Signed-off-by: Michael Scott <>
  • Loading branch information...
mike-scott authored and galak committed Aug 2, 2019
1 parent 0440a81 commit b8909439bf6e11a7bebf779d046c5158b9c5040a
Showing with 28 additions and 22 deletions.
  1. +23 −18 scripts/dts/
  2. +5 −4 scripts/dts/
@@ -90,26 +90,26 @@ class EDT:
The .dts path passed to __init__()
The bindings directory path passed to __init__()
The bindings directory paths passed to __init__()
def __init__(self, dts, bindings_dir):
def __init__(self, dts, bindings_dirs):
EDT constructor. This is the top-level entry point to the library.
Path to device tree .dts file
Path to directory containing bindings, in YAML format. This directory
is recursively searched for .yaml files.
List of paths to directories containing bindings, in YAML format.
These directories are recursively searched for .yaml files.
self.dts_path = dts
self.bindings_dir = bindings_dir
self.bindings_dirs = bindings_dirs

self._dt = DT(dts)


def get_dev(self, path):
@@ -143,7 +143,7 @@ def chosen_dev(self, name):
_err("{} in /chosen points to {}, which does not exist"
.format(name, path))

def _init_compat2binding(self, bindings_dir):
def _init_compat2binding(self, bindings_dirs):
# Creates self._compat2binding. This is a dictionary that maps
# (<compatible>, <bus>) tuples (both strings) to (<binding>, <path>)
# tuples. <binding> is the binding in parsed PyYAML format, and <path>
@@ -160,7 +160,7 @@ def _init_compat2binding(self, bindings_dir):
# are loaded.

dt_compats = _dt_compats(self._dt)
self._binding_paths = _binding_paths(bindings_dir)
self._binding_paths = _binding_paths(bindings_dirs)

# Add '!include foo.yaml' handling.
@@ -238,8 +238,8 @@ def _init_devices(self):

def __repr__(self):
return "<EDT for '{}', binding directory '{}'>".format(
self.dts_path, self.bindings_dir)
return "<EDT for '{}', binding directories '{}'>".format(
self.dts_path, self.bindings_dirs)

class Device:
@@ -1009,14 +1009,19 @@ def _dt_compats(dt):
for compat in node.props["compatible"].to_strings()}

def _binding_paths(bindings_dir):
def _binding_paths(bindings_dirs):
# Returns a list with the paths to all bindings (.yaml files) in
# 'bindings_dir'
# 'bindings_dirs'

return [os.path.join(root, filename)
for root, _, filenames in os.walk(bindings_dir)
for filename in filenames
if filename.endswith(".yaml")]
binding_paths = []

for bindings_dir in bindings_dirs:
for root, _, filenames in os.walk(bindings_dir):
for filename in filenames:
if filename.endswith(".yaml"):
binding_paths.append(os.path.join(root, filename))

return binding_paths

def _binding_compat(binding_path):
@@ -31,7 +31,7 @@ def main():
args = parse_args()

edt = edtlib.EDT(args.dts, args.bindings_dir)
edt = edtlib.EDT(args.dts, args.bindings_dirs)
except edtlib.EDTError as e:
sys.exit("device tree error: " + str(e))

@@ -40,7 +40,7 @@ def main():

out_comment("Generated by", blank_before=False)
out_comment("DTS input file: " + args.dts, blank_before=False)
out_comment("Directory with bindings: " + args.bindings_dir,
out_comment("Directories with bindings: " + ", ".join(args.bindings_dirs),

active_compats = set()
@@ -114,8 +114,9 @@ def parse_args():

parser = argparse.ArgumentParser()
parser.add_argument("--dts", required=True, help="DTS file")
parser.add_argument("--bindings-dir", required=True,
help="directory with bindings in YAML format")
parser.add_argument("--bindings-dirs", nargs='+', required=True,
help="directory with bindings in YAML format, "
"we allow multiple")
parser.add_argument("--header-out", required=True,
help="path to write header to")
parser.add_argument("--conf-out", required=True,

0 comments on commit b890943

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