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>
diff --git a/tools/dtoc/fdt_select.py b/tools/dtoc/fdt_select.py
index 681dfbf..18a36d8 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