Skip to contentSkip to conversation

libfdt: Reduce duplicated copies of libfdt

PATCH New Masahiro Yamada 3 participants 17 messages Oct 17, 2017 – Nov 17, 2017

lore
Share & tools
lore
#0 lore raw

cover libfdt: Reduce duplicated copies of libfdt

Recently, U-Boot switched to the bundled DTC approach. This means we have two copies, lib/libfdt and scripts/dtc/libfdt.

Ideally, we should change lib/libfdt to #include scripts/dtc/libfdt.

One big problem is lib/libfdt is locally modified (fdt_ro.c fdt_wip.c fdt_rw.c) and makes our life difficult.

For now I synced only 6 files.

This series depends on
"pylibfdt: compile pylibfdt in scripts/dtc/pylibfdt only when necessary"
http://patchwork.ozlabs.org/project/uboot/list/?series=8554

Masahiro Yamada (5):
libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*
libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*
tools: use files from scripts/dtc/libfdt where possible linux/types.h: add typedef of uintptr_t
lib: libfdt: wrap scripts/dtc/libfdt/* where possible

 include/fdt.h                 |   2 +-
 include/libfdt_env.h          |   6 -
 include/linux/libfdt.h        |  17 +
 include/linux/libfdt_env.h    |  22 ++
 include/linux/types.h         |   2 +
 lib/libfdt/Makefile           |  17 +-
 lib/libfdt/fdt.c              | 212 +----------
 lib/libfdt/fdt.h              |  67 ----
 lib/libfdt/fdt_addresses.c    |  57 +--
 lib/libfdt/fdt_empty_tree.c   |  39 +-
 lib/libfdt/fdt_overlay.c      | 863 +-----------------------------------------
 lib/libfdt/fdt_strerror.c     |  63 +--
 lib/libfdt/fdt_sw.c           | 256 +------------
 lib/libfdt/libfdt_internal.h  |  51 +--
 tools/Makefile                |  15 +-
 tools/libfdt/fdt.c            |   2 +
 tools/libfdt/fdt_addresses.c  |   2 +
 tools/libfdt/fdt_empty_tree.c |   2 +
 tools/libfdt/fdt_overlay.c    |   2 +
 tools/libfdt/fdt_strerror.c   |   2 +
 tools/libfdt/fdt_sw.c         |   2 +
 21 files changed, 89 insertions(+), 1612 deletions(-)
 create mode 100644 include/linux/libfdt.h
 create mode 100644 include/linux/libfdt_env.h
 delete mode 100644 lib/libfdt/fdt.h
 create mode 100644 tools/libfdt/fdt.c
 create mode 100644 tools/libfdt/fdt_addresses.c
 create mode 100644 tools/libfdt/fdt_empty_tree.c
 create mode 100644 tools/libfdt/fdt_overlay.c
 create mode 100644 tools/libfdt/fdt_strerror.c
 create mode 100644 tools/libfdt/fdt_sw.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*

Fortunately, U-Boot did not modify fdt.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

---

 include/fdt.h    |  2 +-
 lib/libfdt/fdt.h | 67 --------------------------------------------------------
 2 files changed, 1 insertion(+), 68 deletions(-)
 delete mode 100644 lib/libfdt/fdt.h
include/fdt.h +1 -1
index 7ead62e..caeadbf 100644
@@ -1 +1 @@
-#include <../lib/libfdt/fdt.h>
+#include <../scripts/dtc/libfdt/fdt.h>
lib/libfdt/fdt.h deleted +0 -67

67 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/5 libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*

Hi Masahiro,

Quoted 5 lines · Masahiro Yamada

Fortunately, U-Boot did not modify fdt.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

Quoted 7 lines

---

 include/fdt.h    |  2 +-
 lib/libfdt/fdt.h | 67 --------------------------------------------------------
 2 files changed, 1 insertion(+), 68 deletions(-)
 delete mode 100644 lib/libfdt/fdt.h

There was a recent change to make this use the file in lib/libfdt. That makes it easier to sync with upstream dtc.

Can you please explain in a little more detail the motivation for this patch?

Regards,
Simon

#3 lore raw

PATCH 1/5 libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*

Hi Simon,

2017-10-22 23:35 GMT+09:00 Simon Glass <[email protected]>:

Quoted 17 lines

Hi Masahiro,

Quoted 5 lines · Masahiro Yamada

Fortunately, U-Boot did not modify fdt.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

Quoted 7 lines

---

 include/fdt.h    |  2 +-
 lib/libfdt/fdt.h | 67 --------------------------------------------------------
 2 files changed, 1 insertion(+), 68 deletions(-)
 delete mode 100644 lib/libfdt/fdt.h
Quoted 5 lines

There was a recent change to make this use the file in lib/libfdt. That makes it easier to sync with upstream dtc.

Can you please explain in a little more detail the motivation for this patch?

lib/libfdt was the central sync point of libfdt,
but the situation changed by the switch to the bundled DTC approach.

Now we have two copies in lib/libfdt and scripts/dtc/libfdt.

See Linux.
scripts/dtc is periodically synced with DTC, including scripts/dtc/libfdt. lib/fdt* are wrappers to scripts/dtc/libfdt/fdt*
I think this is very successful.

So, I am trying to leave only scripts/dtc/libfdt
and turn others into wrappers of them.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

PATCH 1/5 libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*

In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

Fortunately, U-Boot did not modify fdt.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/e30c6fea/attachment.sig>
#5 lore raw

PATCH 2/5 libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*

In reply to Masahiro Yamada

Fortunately, U-Boot did not modify libfdt_internal.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

---

 lib/libfdt/libfdt_internal.h | 51 +-------------------------------------------
 1 file changed, 1 insertion(+), 50 deletions(-)
lib/libfdt/libfdt_internal.h +1 -50
index 9a79fe8..5197c5d 100644
@@ -1,50 +1 @@
-#ifndef _LIBFDT_INTERNAL_H
-#define _LIBFDT_INTERNAL_H
-/*
- * libfdt - Flat Device Tree manipulation
- * Copyright (C) 2006 David Gibson, IBM Corporation.
- * SPDX-License-Identifier:	GPL-2.0+ BSD-2-Clause
- */
-#include <fdt.h>
-
-#define FDT_ALIGN(x, a)		(((x) + (a) - 1) & ~((a) - 1))
-#define FDT_TAGALIGN(x)		(FDT_ALIGN((x), FDT_TAGSIZE))
-
-#define FDT_CHECK_HEADER(fdt) \
-	{ \
-		int __err; \
-		if ((__err = fdt_check_header(fdt)) != 0) \
-			return __err; \
-	}
-
-int _fdt_check_node_offset(const void *fdt, int offset);
-int _fdt_check_prop_offset(const void *fdt, int offset);
-const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
-int _fdt_node_end_offset(void *fdt, int nodeoffset);
-
-static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
-{
-	return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
-}
-
-static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
-{
-	return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
-}
-
-static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
-{
-	const struct fdt_reserve_entry *rsv_table =
-		(const struct fdt_reserve_entry *)
-		((const char *)fdt + fdt_off_mem_rsvmap(fdt));
-
-	return rsv_table + n;
-}
-static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
-{
-	return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
-}
-
-#define FDT_SW_MAGIC		(~FDT_MAGIC)
-
-#endif /* _LIBFDT_INTERNAL_H */
+#include "../../scripts/dtc/libfdt/libfdt_internal.h"
Signature · 1 line
2.7.4
#6 lore raw

PATCH 2/5 libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*

Quoted 6 lines · Masahiro Yamada

Fortunately, U-Boot did not modify libfdt_internal.h locally.

Change it to a wrapper of scripts/dtc/libfdt/fdt.h, which will be periodically synced with the upstream DTC (or kernel).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/f8b83fcc/attachment.sig>
#7 lore raw

PATCH 3/5 tools: use files from scripts/dtc/libfdt where possible

In reply to Masahiro Yamada

Prior to this commit, tools/Makefile pulls all libfdt files from lib/libfdt.

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

This commit changes them to #include ones from scripts/dtc/libfdt.

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

I did not touch them in order to avoid unpredictable impact.

The fdt_region.c is U-Boot own file. This is also borrowed from lib/libfdt/.

---

 tools/Makefile                | 15 ++++++++++-----
 tools/libfdt/fdt.c            |  2 ++
 tools/libfdt/fdt_addresses.c  |  2 ++
 tools/libfdt/fdt_empty_tree.c |  2 ++
 tools/libfdt/fdt_overlay.c    |  2 ++
 tools/libfdt/fdt_strerror.c   |  2 ++
 tools/libfdt/fdt_sw.c         |  2 ++
 7 files changed, 22 insertions(+), 5 deletions(-)
 create mode 100644 tools/libfdt/fdt.c
 create mode 100644 tools/libfdt/fdt_addresses.c
 create mode 100644 tools/libfdt/fdt_empty_tree.c
 create mode 100644 tools/libfdt/fdt_overlay.c
 create mode 100644 tools/libfdt/fdt_strerror.c
 create mode 100644 tools/libfdt/fdt_sw.c
tools/Makefile +10 -5
index 2b87e18..acbcd87 100644
@@ -58,12 +58,17 @@ hostprogs-y += dumpimage mkimage
 hostprogs-$(CONFIG_FIT_SIGNATURE) += fit_info fit_check_sign
 
 FIT_SIG_OBJS-$(CONFIG_FIT_SIGNATURE) := common/image-sig.o
-# Flattened device tree objects
-LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c  \
-			fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \
-			fdt_region.c
 
-LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS)))
+# The following files are synced with upstream DTC.
+# Use synced versions from scripts/dtc/libfdt/.
+LIBFDT_SRCS_SYNCED := fdt.c fdt_sw.c fdt_strerror.c fdt_empty_tree.c \
+		      fdt_addresses.c fdt_overlay.c
+# The following files are locally modified for U-Boot (unfotunately).
+# Use U-Boot own versions from lib/libfdt/.
+LIBFDT_SRCS_UNSYNCED := fdt_ro.c fdt_wip.c fdt_rw.c fdt_region.c
+
+LIBFDT_OBJS := $(addprefix libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_SYNCED))) \
+	       $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_SRCS_UNSYNCED)))
 
 RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
 					rsa-sign.o rsa-verify.o rsa-checksum.o \
tools/libfdt/fdt.c new file +2 -0
new file mode 100644
index 0000000..8ba8091
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt.c"
tools/libfdt/fdt_addresses.c new file +2 -0
new file mode 100644
index 0000000..242a2c0
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt_addresses.c"
tools/libfdt/fdt_empty_tree.c new file +2 -0
new file mode 100644
index 0000000..9ccbb1f
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt_empty_tree.c"
tools/libfdt/fdt_overlay.c new file +2 -0
new file mode 100644
index 0000000..801ec37
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt_overlay.c"
tools/libfdt/fdt_strerror.c new file +2 -0
new file mode 100644
index 0000000..d7ed70b
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt_strerror.c"
tools/libfdt/fdt_sw.c new file +2 -0
new file mode 100644
index 0000000..ed6b327
@@ -0,0 +1,2 @@
+#include "fdt_host.h"
+#include "../scripts/dtc/libfdt/fdt_sw.c"
Signature · 1 line
2.7.4
#8 lore raw

PATCH 3/5 tools: use files from scripts/dtc/libfdt where possible

Quoted 13 lines · Masahiro Yamada

Prior to this commit, tools/Makefile pulls all libfdt files from lib/libfdt.

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

This commit changes them to #include ones from scripts/dtc/libfdt.

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

Quoted 6 lines

I did not touch them in order to avoid unpredictable impact.

The fdt_region.c is U-Boot own file. This is also borrowed from lib/libfdt/.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/57043a96/attachment.sig>
#9 lore raw

PATCH 4/5 linux/types.h: add typedef of uintptr_t

In reply to Masahiro Yamada

Add this typedef in the same place as in Linux. This is necessary to refactor libfdt inclusion.

U-Boot also defines it in include/compiler.h. Of course it should not do that, but I do not want to open a can of worms.

---

 include/linux/types.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/types.h +2 -0
index 416fa66..7c33e7a 100644
@@ -24,6 +24,8 @@ typedef __kernel_gid32_t	gid_t;
 typedef __kernel_uid16_t        uid16_t;
 typedef __kernel_gid16_t        gid16_t;
 
+typedef unsigned long		uintptr_t;
+
 #ifdef CONFIG_UID16
 /* This is defined by include/asm-{arch}/posix_types.h */
 typedef __kernel_old_uid_t	old_uid_t;
Signature · 1 line
2.7.4
#10 lore raw

PATCH 4/5 linux/types.h: add typedef of uintptr_t

Quoted 7 lines · Masahiro Yamada

Add this typedef in the same place as in Linux. This is necessary to refactor libfdt inclusion.

U-Boot also defines it in include/compiler.h. Of course it should not do that, but I do not want to open a can of worms.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/f6fd2698/attachment.sig>
#11 lore raw

PATCH 5/5 lib: libfdt: wrap scripts/dtc/libfdt/* where possible

In reply to Masahiro Yamada

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import <linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5.

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

The fdt_region.c is U-Boot own file.

I did not touch them in order to avoid unpredictable impact.

---

 include/libfdt_env.h        |   6 -
 include/linux/libfdt.h      |  17 +
 include/linux/libfdt_env.h  |  22 ++
 lib/libfdt/Makefile         |  17 +-
 lib/libfdt/fdt.c            | 212 +----------
 lib/libfdt/fdt_addresses.c  |  57 +--
 lib/libfdt/fdt_empty_tree.c |  39 +-
 lib/libfdt/fdt_overlay.c    | 863 +-------------------------------------------
 lib/libfdt/fdt_strerror.c   |  63 +---
 lib/libfdt/fdt_sw.c         | 256 +------------
 10 files changed, 63 insertions(+), 1489 deletions(-)
 create mode 100644 include/linux/libfdt.h
 create mode 100644 include/linux/libfdt_env.h
include/libfdt_env.h +0 -6
index 6c6845f..273b5d3 100644
@@ -23,12 +23,6 @@ typedef __be64 fdt64_t;
 #define fdt64_to_cpu(x)		be64_to_cpu(x)
 #define cpu_to_fdt64(x)		cpu_to_be64(x)
 
-#ifdef __UBOOT__
-#include <vsprintf.h>
-
-#define strtoul(cp, endp, base)	simple_strtoul(cp, endp, base)
-#endif
-
 /* adding a ramdisk needs 0x44 bytes in version 2008.10 */
 #define FDT_RAMDISK_OVERHEAD	0x80
 
include/linux/libfdt.h new file +17 -0
new file mode 100644
index 0000000..2a663c6
@@ -0,0 +1,17 @@
+#ifndef _LIBFDT_ENV_H
+#define _LIBFDT_ENV_H
+
+#include <linux/string.h>
+
+#include <asm/byteorder.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 */
include/linux/libfdt_env.h new file +22 -0
new file mode 100644
index 0000000..8178f91
@@ -0,0 +1,22 @@
+#ifndef _LIBFDT_ENV_H
+#define _LIBFDT_ENV_H
+
+#include <linux/string.h>
+
+#include <asm/byteorder.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)
+
+/* U-Boot: for strtoul in fdt_overlay.c */
+#include <vsprintf.h>
+
+#define strtoul(cp, endp, base)	simple_strtoul(cp, endp, base)
+
+#endif /* _LIBFDT_ENV_H */
lib/libfdt/Makefile +12 -5
index 6ef8290..369bbf9 100644
@@ -5,15 +5,22 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+# Use upstream code.
 obj-y += \
 	fdt.o \
-	fdt_ro.o \
-	fdt_rw.o \
 	fdt_strerror.o \
 	fdt_sw.o \
-	fdt_wip.o \
 	fdt_empty_tree.o \
-	fdt_addresses.o \
-	fdt_region.o
+	fdt_addresses.o
 
 obj-$(CONFIG_OF_LIBFDT_OVERLAY) += fdt_overlay.o
+
+# Locally modified for U-Boot.
+# TODO: split out the local modifiction.
+obj-y += \
+	fdt_ro.o \
+	fdt_rw.o \
+	fdt_wip.o \
+
+# U-Boot own file
+obj-y += fdt_region.o
lib/libfdt/fdt.c +2 -210

212 lines not on this page · raw message

lib/libfdt/fdt_addresses.c +2 -55

57 lines not on this page · raw message

lib/libfdt/fdt_empty_tree.c +2 -37
index 6fde1eb..2b4ae10 100644
@@ -1,37 +1,2 @@
-/*
- * libfdt - Flat Device Tree manipulation
- * Copyright (C) 2012 David Gibson, IBM Corporation.
- * SPDX-License-Identifier:	GPL-2.0+ BSD-2-Clause
- */
-#include <libfdt_env.h>
-#include <fdt.h>
-#include <libfdt.h>
-
-#include "libfdt_internal.h"
-
-int fdt_create_empty_tree(void *buf, int bufsize)
-{
-	int err;
-
-	err = fdt_create(buf, bufsize);
-	if (err)
-		return err;
-
-	err = fdt_finish_reservemap(buf);
-	if (err)
-		return err;
-
-	err = fdt_begin_node(buf, "");
-	if (err)
-		return err;
-
-	err =  fdt_end_node(buf);
-	if (err)
-		return err;
-
-	err = fdt_finish(buf);
-	if (err)
-		return err;
-
-	return fdt_open_into(buf, buf, bufsize);
-}
+#include <linux/libfdt_env.h>
+#include "../../scripts/dtc/libfdt/fdt_empty_tree.c"
lib/libfdt/fdt_overlay.c +2 -861

863 lines not on this page · raw message

lib/libfdt/fdt_strerror.c +2 -61

63 lines not on this page · raw message

lib/libfdt/fdt_sw.c +2 -254

256 lines not on this page · raw message

Signature · 1 line
2.7.4
#12 lore raw

PATCH 5/5 lib: libfdt: wrap scripts/dtc/libfdt/* where possible

Hi Masahiro,

Quoted 19 lines · Masahiro Yamada

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import <linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5.

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

The fdt_region.c is U-Boot own file.

I did not touch them in order to avoid unpredictable impact.

---

Quoted 14 lines
 include/libfdt_env.h        |   6 -
 include/linux/libfdt.h      |  17 +
 include/linux/libfdt_env.h  |  22 ++
 lib/libfdt/Makefile         |  17 +-
 lib/libfdt/fdt.c            | 212 +----------
 lib/libfdt/fdt_addresses.c  |  57 +--
 lib/libfdt/fdt_empty_tree.c |  39 +-
 lib/libfdt/fdt_overlay.c    | 863 +-------------------------------------------
 lib/libfdt/fdt_strerror.c   |  63 +---
 lib/libfdt/fdt_sw.c         | 256 +------------
 10 files changed, 63 insertions(+), 1489 deletions(-)
 create mode 100644 include/linux/libfdt.h
 create mode 100644 include/linux/libfdt_env.h

I am not hugely keen on this. At present I can compare upstream with U-Boot directly. Why do I need to worry about scripts/? Why are the files even duplicated in there?

Regards,
Simon

#13 lore raw

PATCH 5/5 lib: libfdt: wrap scripts/dtc/libfdt/* where possible

2017-10-22 23:35 GMT+09:00 Simon Glass <[email protected]>:

Quoted 38 lines

Hi Masahiro,

Quoted 19 lines · Masahiro Yamada

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import <linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5.

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

The fdt_region.c is U-Boot own file.

I did not touch them in order to avoid unpredictable impact.

---

Quoted 14 lines
 include/libfdt_env.h        |   6 -
 include/linux/libfdt.h      |  17 +
 include/linux/libfdt_env.h  |  22 ++
 lib/libfdt/Makefile         |  17 +-
 lib/libfdt/fdt.c            | 212 +----------
 lib/libfdt/fdt_addresses.c  |  57 +--
 lib/libfdt/fdt_empty_tree.c |  39 +-
 lib/libfdt/fdt_overlay.c    | 863 +-------------------------------------------
 lib/libfdt/fdt_strerror.c   |  63 +---
 lib/libfdt/fdt_sw.c         | 256 +------------
 10 files changed, 63 insertions(+), 1489 deletions(-)
 create mode 100644 include/linux/libfdt.h
 create mode 100644 include/linux/libfdt_env.h
Quoted 3 lines

I am not hugely keen on this. At present I can compare upstream with U-Boot directly. Why do I need to worry about scripts/? Why are the files even duplicated in there?

There are two copies. Is it ok to keep both?

As I explained in the following patch
http://patchwork.ozlabs.org/patch/826742/
scripts/dtc reflects the directory structure of the upstream DTC.

So, I believe syncing scripts/lib/libfdt is consistent
and requires least effort to import outcomes from upstream DTC/kernel.

I am opposed to edit file locally.
This is make the sync work difficult.
We can split U-Boot specific functions out to lib/libfdt/fdt-local.c (the file name is not important, it could be anything)

Signature · 2 lines
Best Regards
Masahiro Yamada
#14 lore raw

PATCH 5/5 lib: libfdt: wrap scripts/dtc/libfdt/* where possible

In reply to Masahiro Yamada
Quoted 9 lines · Masahiro Yamada

lib/libfdt/ and scripts/dtc/libfdt have the same copies for the followings 6 files:
fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c fdt_sw.c

Make them a wrapper of scripts/dtc/libfdt/*. This is exactly what Linux does to sync libfdt. In order to make is possible, import <linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5.

Quoted 8 lines

Unfortunately, U-Boot locally modified the following 3 files:
fdt_ro.c fdt_wip.c fdt_rw.c

The fdt_region.c is U-Boot own file.

I did not touch them in order to avoid unpredictable impact.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/cb3e6fab/attachment.sig>
#15 lore raw

cover libfdt: Reduce duplicated copies of libfdt

In reply to Masahiro Yamada

2017-10-17 22:30 GMT+09:00 Masahiro Yamada <[email protected]>:

Quoted 16 lines

Recently, U-Boot switched to the bundled DTC approach. This means we have two copies, lib/libfdt and scripts/dtc/libfdt.

Ideally, we should change lib/libfdt to #include scripts/dtc/libfdt.

One big problem is lib/libfdt is locally modified (fdt_ro.c fdt_wip.c fdt_rw.c) and makes our life difficult.

For now I synced only 6 files.

This series depends on
"pylibfdt: compile pylibfdt in scripts/dtc/pylibfdt only when necessary"
http://patchwork.ozlabs.org/project/uboot/list/?series=8554

Quoted 7 lines

Masahiro Yamada (5):
libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*
libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*
tools: use files from scripts/dtc/libfdt where possible linux/types.h: add typedef of uintptr_t
lib: libfdt: wrap scripts/dtc/libfdt/* where possible

This series does not cleanly apply any more.

Tom,
Do you need v2?

Signature · 2 lines
Best Regards
Masahiro Yamada
#16 lore raw

cover libfdt: Reduce duplicated copies of libfdt

Quoted 25 lines · Masahiro Yamada

2017-10-17 22:30 GMT+09:00 Masahiro Yamada <[email protected]>:

Quoted 16 lines

Recently, U-Boot switched to the bundled DTC approach. This means we have two copies, lib/libfdt and scripts/dtc/libfdt.

Ideally, we should change lib/libfdt to #include scripts/dtc/libfdt.

One big problem is lib/libfdt is locally modified (fdt_ro.c fdt_wip.c fdt_rw.c) and makes our life difficult.

For now I synced only 6 files.

This series depends on
"pylibfdt: compile pylibfdt in scripts/dtc/pylibfdt only when necessary"
http://patchwork.ozlabs.org/project/uboot/list/?series=8554

Quoted 6 lines

Masahiro Yamada (5):
libfdt: change fdt.h to a wrapper of scripts/dtc/libfdt/*
libfdt: change libfdt_internal.h to a wrapper of scripts/dtc/libfdt/*
tools: use files from scripts/dtc/libfdt where possible linux/types.h: add typedef of uintptr_t
lib: libfdt: wrap scripts/dtc/libfdt/* where possible

Quoted 4 lines

This series does not cleanly apply any more.

Tom,
Do you need v2?

I assume that it's failing now on the <...> -> "..." change, and that there's been no changes in linux-next in this area since v1? If so, I'll just fix it when I apply after release, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171107/a90353d3/attachment.sig>