summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt_select.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-07-25 18:59:04 -0600
committerSimon Glass <sjg@chromium.org>2016-09-18 21:04:38 -0600
commita06a34b2031e0797892e188595bfb305cd9719ab (patch)
tree7980eea5b4835aeee5f8cc5dcd644aeb486811da /tools/dtoc/fdt_select.py
parent66051b1f59dfba48566dc3e0eee4c093e1104590 (diff)
downloadu-boot-imx-a06a34b2031e0797892e188595bfb305cd9719ab.zip
u-boot-imx-a06a34b2031e0797892e188595bfb305cd9719ab.tar.gz
u-boot-imx-a06a34b2031e0797892e188595bfb305cd9719ab.tar.bz2
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.py9
1 files changed, 6 insertions, 3 deletions
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