From 7f69a03f72e361d970728b17f7527d92e394aeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 11 Aug 2021 15:14:51 -0700 Subject: [PATCH] scripts: gen_defines: refactor write_special_props MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the partition handling code into its own function and rework the comment. This is prep work for adding additional generated macros to this function. Signed-off-by: Martí Bolívar --- scripts/dts/gen_defines.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index f95219ded98..365e950fc82 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -352,20 +352,16 @@ def write_special_props(node): # data cannot otherwise be obtained from write_vanilla_props() # results - global flash_area_num - - out_comment("Special property macros:") - # Macros that are special to the devicetree specification + out_comment("Macros for properties that are special in the specification:") write_regs(node) write_interrupts(node) write_compatibles(node) write_status(node) - if node.parent and "fixed-partitions" in node.parent.compats: - macro = f"{node.z_path_id}_PARTITION_ID" - out_dt_define(macro, flash_area_num) - flash_area_num += 1 + # Macros that are special to bindings inherited from Linux, which + # we can't capture with the current bindings language. + write_fixed_partitions(node) def write_regs(node): # reg property: edtlib knows the right #address-cells and @@ -513,6 +509,18 @@ def write_status(node): out_dt_define(f"{node.z_path_id}_STATUS_{str2ident(node.status)}", 1) +def write_fixed_partitions(node): + # Macros for child nodes of each fixed-partitions node. + + if not (node.parent and "fixed-partitions" in node.parent.compats): + return + + global flash_area_num + out_comment("fixed-partitions identifier:") + out_dt_define(f"{node.z_path_id}_PARTITION_ID", flash_area_num) + flash_area_num += 1 + + def write_vanilla_props(node): # Writes macros for any and all properties defined in the # "properties" section of the binding for the node.