summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt_util.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-17 13:25:31 -0600
committerSimon Glass <sjg@chromium.org>2018-08-01 16:30:47 -0600
commitdc08ecc90cc57d7ca73f837a847a81c8b1e8af79 (patch)
tree1ba995f339fcd3235ee8c328f860c66931dadc12 /tools/dtoc/fdt_util.py
parentdbf6be9f7f3b650ae5248eb7e2c00e94b4da867c (diff)
dtoc: Add missing comments to fdt_util
This module has a few missing comments. Add them. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt_util.py')
-rw-r--r--tools/dtoc/fdt_util.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py
index 5b631419a9..05cb9c0775 100644
--- a/tools/dtoc/fdt_util.py
+++ b/tools/dtoc/fdt_util.py
@@ -5,6 +5,9 @@
# Written by Simon Glass <sjg@chromium.org>
#
+# Utility functions for reading from a device tree. Once the upstream pylibfdt
+# implementation advances far enough, we should be able to drop these.
+
import os
import struct
import sys
@@ -90,6 +93,16 @@ def EnsureCompiled(fname, capture_stderr=False):
return dtb_output
def GetInt(node, propname, default=None):
+ """Get an integer from a property
+
+ Args:
+ node: Node object to read from
+ propname: property name to read
+ default: Default value to use if the node/property do not exist
+
+ Returns:
+ Integer value read, or default if none
+ """
prop = node.props.get(propname)
if not prop:
return default
@@ -100,6 +113,16 @@ def GetInt(node, propname, default=None):
return value
def GetString(node, propname, default=None):
+ """Get a string from a property
+
+ Args:
+ node: Node object to read from
+ propname: property name to read
+ default: Default value to use if the node/property do not exist
+
+ Returns:
+ String value read, or default if none
+ """
prop = node.props.get(propname)
if not prop:
return default
@@ -110,6 +133,17 @@ def GetString(node, propname, default=None):
return value
def GetBool(node, propname, default=False):
+ """Get an boolean from a property
+
+ Args:
+ node: Node object to read from
+ propname: property name to read
+ default: Default value to use if the node/property do not exist
+
+ Returns:
+ Boolean value read, or default if none (if you set this to True the
+ function will always return True)
+ """
if propname in node.props:
return True
return default