[U-Boot] [PATCH 1/2 RESEND] fdt_support: fdt_translate_address() blob const correctness

Stephen Warren swarren at wwwdotorg.org
Sat Aug 6 08:01:38 CEST 2016


On 08/05/2016 09:36 PM, Simon Glass wrote:
> Hi Stephen,
>
> On 5 August 2016 at 19:41, Simon Glass <sjg at chromium.org> wrote:
>>
>> On 5 August 2016 at 09:47, Stephen Warren <swarren at wwwdotorg.org> wrote:
>>> From: Stephen Warren <swarren at nvidia.com>
>>>
>>> The next patch will call fdt_translate_address() from somewhere with a
>>> "const void *blob" rather than a "void *blob", so fdt_translate_address()
>>> must accept a const pointer too. Constify the minimum number of function
>>> parameters to achieve this.
>>>
>>> Signed-off-by: Stephen Warren <swarren at nvidia.com>
>>> Acked-by: Simon Glass <sjg at chromium.org>
>>> ---
>>> Re-sending since these didn't show up in patchwork for some reason.
>>>
>>> This series will be a dependency for the Tegra BPMP driver.
>>>
>>>  common/fdt_support.c  | 19 ++++++++++---------
>>>  include/fdt_support.h |  5 +++--
>>>  2 files changed, 13 insertions(+), 11 deletions(-)
>>
>> Applied to u-boot-dm, thanks!
>
> Unfortunately these patches cause some build breakages. Can you please
> take a look?

The following fixes the issues you mentioned. Do you want to squash it 
in or should I resend?

> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index da59f2c8cc07..202058621ae2 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -1055,7 +1055,7 @@ static int of_bus_default_translate(fdt32_t *addr, u64 offset, int na)
>  #ifdef CONFIG_OF_ISA_BUS
>
>  /* ISA bus translator */
> -static int of_bus_isa_match(void *blob, int parentoffset)
> +static int of_bus_isa_match(const void *blob, int parentoffset)
>  {
>  	const char *name;
>
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index 7d99bdb8ca47..e638ca5d6a33 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -113,9 +113,11 @@ fdt_addr_t fdtdec_get_addr_size_fixed(const void *blob, int node,
>  		return FDT_ADDR_T_NONE;
>  	}
>
> +#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_OF_LIBFDT)
>  	if (translate)
>  		addr = fdt_translate_address(blob, node, prop_addr);
>  	else
> +#endif
>  		addr = fdtdec_get_number(prop_addr, na);
>
>  	if (sizep) {

The ifdef is a bit unfortunate but mirrors that ifdefs in 
common/Makefile. An alternative might be to define a weak version of 
fdt_translate_address() in fdtdec.c that does nothing more than call 
fdtdec_get_number(), but that might be even more confusing.


More information about the U-Boot mailing list