[7/7] libfdt: migrate include/libfdt_env.h to a wrapper

Message ID 1515490492-29434-7-git-send-email-yamada.masahiro@socionext.com
State Superseded
Headers show
Series
  • [1/7] libfdt: migrate fdt_rw.c to a wrapper of scripts/dtc/libfdt/fdt_rw.c
Related show

Commit Message

Masahiro Yamada Jan. 9, 2018, 9:34 a.m.
libfdt_env.h is supposed to provide system-dependent defines.

scripts/dtc/libfdt/libfdt_env.h from upstream DTC is suitable
for user-space, so we should use this for USE_HOSTCC case.

For compiling U-Boot, we need to override such system-dependent
defines, so use <linux/libfdt_env.h> imported from Linux.

I can rip off the include/libfdt_env.h from HOST_EXTRACFLAGS.
Adding all sort of stuff to the include path just for suppressing
errors is a crazy idea.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 include/libfdt_env.h | 29 +++++------------------------
 tools/Makefile       |  2 +-
 2 files changed, 6 insertions(+), 25 deletions(-)

Comments

Simon Glass Jan. 16, 2018, 2:56 p.m. | #1
On 9 January 2018 at 01:34, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> libfdt_env.h is supposed to provide system-dependent defines.
>
> scripts/dtc/libfdt/libfdt_env.h from upstream DTC is suitable
> for user-space, so we should use this for USE_HOSTCC case.
>
> For compiling U-Boot, we need to override such system-dependent
> defines, so use <linux/libfdt_env.h> imported from Linux.
>
> I can rip off the include/libfdt_env.h from HOST_EXTRACFLAGS.
> Adding all sort of stuff to the include path just for suppressing
> errors is a crazy idea.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  include/libfdt_env.h | 29 +++++------------------------
>  tools/Makefile       |  2 +-
>  2 files changed, 6 insertions(+), 25 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

I'm not really sure why we want to use linux/libfdt.h though... Can
you add some details in the patch?

- Simon
Masahiro Yamada Jan. 16, 2018, 4:33 p.m. | #2
2018-01-16 23:56 GMT+09:00 Simon Glass <sjg@chromium.org>:
> On 9 January 2018 at 01:34, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> libfdt_env.h is supposed to provide system-dependent defines.
>>
>> scripts/dtc/libfdt/libfdt_env.h from upstream DTC is suitable
>> for user-space, so we should use this for USE_HOSTCC case.
>>
>> For compiling U-Boot, we need to override such system-dependent
>> defines, so use <linux/libfdt_env.h> imported from Linux.
>>
>> I can rip off the include/libfdt_env.h from HOST_EXTRACFLAGS.
>> Adding all sort of stuff to the include path just for suppressing
>> errors is a crazy idea.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>
>>  include/libfdt_env.h | 29 +++++------------------------
>>  tools/Makefile       |  2 +-
>>  2 files changed, 6 insertions(+), 25 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> I'm not really sure why we want to use linux/libfdt.h though... Can
> you add some details in the patch?
>

I just borrowed as much code from Linux as possible.

This is successful in most cases.
I trust kernel developers.


<linux/libfdt_env.h> contains environments for the target board.


<libfdt_env.h> selects either of them
depending on USE_HOSTCC.

Maybe we can move USB_HOSTCC case to tools/ in the future,
but this series makes the code much cleaner than the current one.

Patch

diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index ea26979..d7e9d32 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -1,24 +1,5 @@ 
-/*
- * libfdt - Flat Device Tree manipulation (build/run environment adaptation)
- * Copyright (C) 2007 Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
- * Original version written by David Gibson, IBM Corporation.
- *
- * SPDX-License-Identifier:	LGPL-2.1+
- */
-
-#ifndef _LIBFDT_ENV_H
-#define _LIBFDT_ENV_H
-
-#include "compiler.h"
-#include "linux/types.h"
-
-typedef __be16 fdt16_t;
-typedef __be32 fdt32_t;
-typedef __be64 fdt64_t;
-
-#define fdt32_to_cpu(x)		be32_to_cpu(x)
-#define cpu_to_fdt32(x)		cpu_to_be32(x)
-#define fdt64_to_cpu(x)		be64_to_cpu(x)
-#define cpu_to_fdt64(x)		cpu_to_be64(x)
-
-#endif /* _LIBFDT_ENV_H */
+#ifdef USE_HOSTCC
+#include "../scripts/dtc/libfdt/libfdt_env.h"
+#else
+#include <linux/libfdt_env.h>
+#endif
diff --git a/tools/Makefile b/tools/Makefile
index 3274487..2333646 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -238,7 +238,7 @@  endif # !LOGO_BMP
 # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
-HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
+HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
 		$(patsubst -I%,-idirafter%, $(filter -I%, $(UBOOTINCLUDE))) \
 		-I$(srctree)/lib/libfdt \
 		-I$(srctree)/tools \