cmd: fdt: Add support for integer arrays in fdt get value with index
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Thu, 2 Mar 2023 03:08:23 +0000 (04:08 +0100)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Mar 2023 19:40:57 +0000 (11:40 -0800)
commit95d85d0da4ae13946325c39a0dffefcbeaa07a38
tree2435be48c037d966d2be41f6658fd447d4c219ee
parentc2a5d1078027b6c0480eda45bd4d2eae80ceb67e
cmd: fdt: Add support for integer arrays in fdt get value with index

Currently any integer array value is set as long up-to-40 character
hexadecimal string into environment variable when extracted from an
FDT using 'fdt get value path prop index', because the support for
handling integer arrays is not implemented, and fdt_value_env_set()
code falls back into the hash handling behavior instead.

Implement this support simply by checking whether user supplied any
index. If index is set and the property length is multiple of four,
then this is an integer array, and the code would extract value at
specified index.

There is a subtle change where default index is set to -1 instead of 0.
This is OK, since the only place which checks for index to be less or
equal zero is the string array handling code in fdt_value_env_set() and
that code would work perfectly well with index -1 too.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/fdt.c