From b32b581a34832803a34cb34d03cad417b02386ab Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 26 Jul 2017 09:43:44 -0500 Subject: [PATCH] scripts/extract_dts_includes.py: Reduce code for handling chosen names We have the same pattern for how we map a chosen property to the device label that generates a Kconfig define. Rather than duplicating the code over and over again, lets just iterate over a list of defines and chosen properties. This also provides us a list we can use in the future to special case handle the defines associated with names. Signed-off-by: Kumar Gala --- scripts/extract_dts_includes.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/extract_dts_includes.py b/scripts/extract_dts_includes.py index 9daeb42152a..2f564bbf4f1 100755 --- a/scripts/extract_dts_includes.py +++ b/scripts/extract_dts_includes.py @@ -778,21 +778,16 @@ def main(): extract_reg_prop(chosen['zephyr,sram'], None, defs, "CONFIG_SRAM", 1024, None) - if 'zephyr,console' in chosen: - extract_string_prop(chosen['zephyr,console'], None, "label", - "CONFIG_UART_CONSOLE_ON_DEV_NAME", defs) + name_dict = { + "CONFIG_UART_CONSOLE_ON_DEV_NAME": "zephyr,console", + "CONFIG_BLUETOOTH_UART_ON_DEV_NAME": "zephyr,bt-uart", + "CONFIG_UART_PIPE_ON_DEV_NAME": "zephyr,bt-mon-uart", + "CONFIG_BLUETOOTH_MONITOR_ON_DEV_NAME": "zephyr,bt-mon-uart" + } - if 'zephyr,bt-uart' in chosen: - extract_string_prop(chosen['zephyr,bt-uart'], None, "label", - "CONFIG_BLUETOOTH_UART_ON_DEV_NAME", defs) - - if 'zephyr,uart-pipe' in chosen: - extract_string_prop(chosen['zephyr,uart-pipe'], None, "label", - "CONFIG_UART_PIPE_ON_DEV_NAME", defs) - - if 'zephyr,bt-mon-uart' in chosen: - extract_string_prop(chosen['zephyr,bt-mon-uart'], None, "label", - "CONFIG_BLUETOOTH_MONITOR_ON_DEV_NAME", defs) + for k, v in name_dict.items(): + if v in chosen: + extract_string_prop(chosen[v], None, "label", k, defs) # only compute the load offset if a code partition exists and it is not the # same as the flash base address