[PATCH 05/17] pylibfdt: Add Property.as_*int*_array()
Alexey Charkov <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
From: Luca Weiss <[email protected]> Add new methods to handle decoding of int32, uint32, int64 and uint64 arrays. This is a backport of dtc commit a04f69025003 ("pylibfdt: add Property.as_*int*_array()"), without the dtc-side tests, which have no counterpart in U-Boot's test suite. Signed-off-by: Luca Weiss <[email protected]> Signed-off-by: David Gibson <[email protected]> [adapted to U-Boot] Signed-off-by: Alexey Charkov <[email protected]> --- scripts/dtc/pylibfdt/libfdt.i_shipped | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped index c8ac578b367b..735a3bab6d9f 100644 --- a/scripts/dtc/pylibfdt/libfdt.i_shipped +++ b/scripts/dtc/pylibfdt/libfdt.i_shipped @@ -720,6 +720,21 @@ class Property(bytearray): def as_int64(self): return self.as_cell('q') + def as_list(self, fmt): + return list(map(lambda x: x[0], struct.iter_unpack('>' + fmt, self))) + + def as_uint32_list(self): + return self.as_list('L') + + def as_int32_list(self): + return self.as_list('l') + + def as_uint64_list(self): + return self.as_list('Q') + + def as_int64_list(self): + return self.as_list('q') + def as_str(self): """Unicode is supported by decoding from UTF-8""" if self[-1] != 0: -- 2.54.0