dtoc: Support deleting device tree properties
[platform/kernel/u-boot.git] / tools / dtoc / fdt_fallback.py
index 5b0f2a1..0c0ebbc 100644 (file)
@@ -70,6 +70,19 @@ class Node(NodeBase):
 
             node.Scan()
 
+    def DeleteProp(self, prop_name):
+        """Delete a property of a node
+
+        The property is deleted using fdtput.
+
+        Args:
+            prop_name: Name of the property to delete
+        Raises:
+            CommandError if the property does not exist
+        """
+        args = [self._fdt._fname, '-d', self.path, prop_name]
+        command.Output('fdtput', *args)
+        del self.props[prop_name]
 
 class FdtFallback(Fdt):
     """Provides simple access to a flat device tree blob using fdtget/fdtput
@@ -80,6 +93,8 @@ class FdtFallback(Fdt):
 
     def __init__(self, fname):
         Fdt.__init__(self, fname)
+        if self._fname:
+            self._fname = fdt_util.EnsureCompiled(self._fname)
 
     def GetSubNodes(self, node):
         """Returns a list of sub-nodes of a given node
@@ -96,12 +111,11 @@ class FdtFallback(Fdt):
         out = command.Output('fdtget', self._fname, '-l', node)
         return out.strip().splitlines()
 
-    def GetProps(self, node, convert_dashes=False):
+    def GetProps(self, node):
         """Get all properties from a node
 
         Args:
             node: full path to node name to look in
-            convert_dashes: True to convert - to _ in node names
 
         Returns:
             A dictionary containing all the properties, indexed by node name.
@@ -116,8 +130,6 @@ class FdtFallback(Fdt):
         props_dict = {}
         for prop in props:
             name = prop
-            if convert_dashes:
-                prop = re.sub('-', '_', prop)
             props_dict[prop] = self.GetProp(node, name)
         return props_dict