dtoc: Tweak ordering of fdt-offsets refreshing
Once the tree has been synced, thus potentially moving things around in the fdt, we set _cached_offsets to False so that a refresh will happen next time a property is accessed. This 'lazy' refresh doesn't really save much time, since refresh is a very fast operation, just a single walk of the tree. Also, having the refresh happen in the bowels of property access it makes it harder to figure out what is going on. Simplify the code by always doing a refresh before and after a sync. Set _cached_offsets to True immediately after this, in the Refresh() function, since this makes more sense than doing it in the caller. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
37ba9844c2
commit
71719e15e8
@ -646,8 +646,9 @@ class Fdt:
|
||||
Raises:
|
||||
FdtException if auto_resize is False and there is not enough space
|
||||
"""
|
||||
self.CheckCache()
|
||||
self._root.Sync(auto_resize)
|
||||
self.Invalidate()
|
||||
self.Refresh()
|
||||
|
||||
def Pack(self):
|
||||
"""Pack the device tree down to its minimum size
|
||||
@ -656,7 +657,7 @@ class Fdt:
|
||||
build up in the device tree binary.
|
||||
"""
|
||||
CheckErr(self._fdt_obj.pack(), 'pack')
|
||||
self.Invalidate()
|
||||
self.Refresh()
|
||||
|
||||
def GetContents(self):
|
||||
"""Get the contents of the FDT
|
||||
@ -708,11 +709,11 @@ class Fdt:
|
||||
if self._cached_offsets:
|
||||
return
|
||||
self.Refresh()
|
||||
self._cached_offsets = True
|
||||
|
||||
def Refresh(self):
|
||||
"""Refresh the offset cache"""
|
||||
self._root.Refresh(0)
|
||||
self._cached_offsets = True
|
||||
|
||||
def GetStructOffset(self, offset):
|
||||
"""Get the file offset of a given struct offset
|
||||
|
Loading…
Reference in New Issue
Block a user