diff options
author | Simon Glass <sjg@chromium.org> | 2021-07-29 04:23:11 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-08-01 18:05:24 +0300 |
commit | eec44c7218a3c3ce924a282cc46a59e83feb9de1 (patch) | |
tree | 2508a115df4604adc9395b4f72e8ec3ec8fff90f /tools/dtoc/fdt.py | |
parent | ca04494d76bf1152cd9ab1f67af5101c86e0824f (diff) | |
download | u-boot-eec44c7218a3c3ce924a282cc46a59e83feb9de1.tar.xz |
dtoc: Support widening a bool value
At present if we see 'ranges' property (with no value) we assume it is a
boolean, as per the devicetree spec.
But another node may define 'ranges' with a value, forcing us to widen it
to an int array. At present this is not supported and causes an error.
Fix this and add some test cases.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r-- | tools/dtoc/fdt.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 429e95f9a9..32a7aa9829 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -153,6 +153,18 @@ class Prop: specific. """ if self.type.needs_widening(newprop.type): + + # A boolean has an empty value: if it exists it is True and if not + # it is False. So when widening we always start with an empty list + # since the only valid integer property would be an empty list of + # integers. + # e.g. this is a boolean: + # some-prop; + # and it would be widened to int list by: + # some-prop = <1 2>; + if self.type == Type.BOOL: + self.type = Type.INT + self.value = [self.GetEmpty(self.type)] if self.type == Type.INT and newprop.type == Type.BYTE: if type(self.value) == list: new_value = [] |