scripts: dts: gen_defines: Fix issue if there are no compats

We get the following error:

  ValueError: max() arg is an empty sequence

if the compatiable section of the device tree is empty or doesn't exist.
Fix this by havingin max_len get a default value of 0.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-03-25 15:32:58 -05:00 committed by Kumar Gala
parent 9d15e98643
commit 299bfd0553

View file

@ -505,7 +505,7 @@ def write_chosen(edt):
for name, node in edt.chosen_nodes.items():
chosen[f"DT_CHOSEN_{str2ident(name)}"] = f"DT_{node.z_path_id}"
chosen[f"DT_CHOSEN_{str2ident(name)}_EXISTS"] = 1
max_len = max(map(len, chosen))
max_len = max(map(len, chosen), default=0)
for macro, value in chosen.items():
out_define(macro, value, width=max_len)