From be858cffa91fbcd5b8657200fbec1667c65bb1b7 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Thu, 26 Mar 2020 11:50:33 +0000 Subject: plat/stm32: Implement fdt_read_uint32_default() as a wrapper The STM32 platform code uses its own set of FDT helper functions, although some of them are fairly generic. Remove the implementation of fdt_read_uint32_default() and implement it on top of the newly introduced fdt_read_uint32() function, then convert all users over. This also fixes two callers, which were slightly abusing the "default" semantic. Change-Id: I570533362b4846e58dd797a92347de3e0e5abb75 Signed-off-by: Andre Przywara --- common/fdt_wrappers.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common') diff --git a/common/fdt_wrappers.c b/common/fdt_wrappers.c index 394f3b0ca..57e3bcd40 100644 --- a/common/fdt_wrappers.c +++ b/common/fdt_wrappers.c @@ -56,6 +56,19 @@ int fdt_read_uint32(const void *dtb, int node, const char *prop_name, return fdt_read_uint32_array(dtb, node, prop_name, 1, value); } +uint32_t fdt_read_uint32_default(const void *dtb, int node, + const char *prop_name, uint32_t dflt_value) +{ + uint32_t ret = dflt_value; + int err = fdt_read_uint32(dtb, node, prop_name, &ret); + + if (err < 0) { + return dflt_value; + } + + return ret; +} + int fdt_read_uint64(const void *dtb, int node, const char *prop_name, uint64_t *value) { -- cgit v1.2.3