diff options
author | Simon Glass <sjg@chromium.org> | 2016-07-25 18:59:04 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-09-18 21:04:38 -0600 |
commit | a06a34b2031e0797892e188595bfb305cd9719ab (patch) | |
tree | 7980eea5b4835aeee5f8cc5dcd644aeb486811da /tools/dtoc/fdt_select.py | |
parent | 66051b1f59dfba48566dc3e0eee4c093e1104590 (diff) |
dtoc: Create a base class for Fdt
At present we have two separate implementations of the Fdt library, one which
uses fdtget/fdtput and one which uses libfdt (via swig).
Before adding more functionality it makes sense to create a base class for
these. This will allow common functions to be shared, and make the Fdt API
a little clearer.
Create a new fdt.py file with the base class, and adjust fdt_normal.py and
fdt_fallback.py to use it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt_select.py')
-rw-r--r-- | tools/dtoc/fdt_select.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/dtoc/fdt_select.py b/tools/dtoc/fdt_select.py index 681dfbfda0..18a36d88a0 100644 --- a/tools/dtoc/fdt_select.py +++ b/tools/dtoc/fdt_select.py @@ -10,14 +10,17 @@ # fallback one (which uses fdtget and is slower). Both provide the same # interface for this file to use. try: - import fdt_normal as fdt + import fdt_normal have_libfdt = True except ImportError: have_libfdt = False - import fdt_fallback as fdt + import fdt_fallback def FdtScan(fname): """Returns a new Fdt object from the implementation we are using""" - dtb = fdt.Fdt(fname) + if have_libfdt: + dtb = fdt_normal.FdtNormal(fname) + else: + dtb = fdt_fallback.FdtFallback(fname) dtb.Scan() return dtb |