From c1c82b7570148064ce705655db9d261b4dbbbdbe Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Sun, 27 Oct 2019 12:20:59 -0500 Subject: [PATCH] scripts: dts: generate array values as initializer lists Simplify use of property values that have multiple elements by providing all of them in an initializer list, in addition to each one as an enumerated value. For example if a driver requires a sequence of operations with instance-specific delays between stages the durations can be specified with: delays = <30000 20 45000>; and the driver can use: static u32_t delays[] = DT_INST_0_COMPAT_DELAYS; rather than enumerating the instances. This is particularly useful when the number of entries in the array varies per instance, in which case such an initialization is not easily expressed in code. Signed-off-by: Peter A. Bigot --- scripts/dts/gen_defines.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index f848ca4941b..57b0ee4931e 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -190,6 +190,8 @@ def write_props(node): elif prop.type == "array": for i, val in enumerate(prop.val): out_dev(node, "{}_{}".format(ident, i), val) + out_dev(node, ident, + "{" + ", ".join(map(str, prop.val)) + "}") elif prop.type == "string-array": for i, val in enumerate(prop.val): out_dev_s(node, "{}_{}".format(ident, i), val)