dtoc: Move the output code into its own function

The code to generate the tables is quite long. Move the node-output code
into its own function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
Simon Glass 2017-04-22 18:42:21 -06:00
parent ff71f9ac33
commit 49eec8c7f1

View file

@ -301,19 +301,12 @@ class DtbPlatdata:
self.Out(';\n')
self.Out('};\n')
def GenerateTables(self):
"""Generate device defintions for the platform data
def OutputNode(self, node):
"""Output the C code for a node
This writes out C platform data initialisation data and
U_BOOT_DEVICE() declarations for each valid node. See the
documentation in README.of-plat for more information.
Args:
node: node to output
"""
self.Out('#include <common.h>\n')
self.Out('#include <dm.h>\n')
self.Out('#include <dt-structs.h>\n')
self.Out('\n')
node_txt_list = []
for node in self._valid_nodes:
struct_name = self.GetCompatName(node)
var_name = Conv_name_to_c(node.name)
self.Buf('static struct %s%s %s%s = {\n' %
@ -359,6 +352,21 @@ class DtbPlatdata:
self.Buf('};\n')
self.Buf('\n')
def GenerateTables(self):
"""Generate device defintions for the platform data
This writes out C platform data initialisation data and
U_BOOT_DEVICE() declarations for each valid node. See the
documentation in README.of-plat for more information.
"""
self.Out('#include <common.h>\n')
self.Out('#include <dm.h>\n')
self.Out('#include <dt-structs.h>\n')
self.Out('\n')
node_txt_list = []
for node in self._valid_nodes:
self.OutputNode(node)
# Output phandle target nodes first, since they may be referenced
# by others
if 'phandle' in node.props: