diff mbox series

[V5,3/5] scripts: dtc: Remove the unused fdtdump.c file

Message ID f63b3fd7fadf8912e8e7e8653df45b5b78f5d005.1611124778.git.viresh.kumar@linaro.org
State Superseded
Headers show
Series dt: build overlays | expand

Commit Message

Viresh Kumar Jan. 20, 2021, 7:06 a.m. UTC
This was copied from external DTC repository long back and isn't used
anymore. Over that the dtc tool can be used to generate the dts source
back from the dtb. Remove the unused fdtdump.c file.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

---
 scripts/dtc/fdtdump.c | 163 ------------------------------------------
 1 file changed, 163 deletions(-)
 delete mode 100644 scripts/dtc/fdtdump.c

-- 
2.25.0.rc1.19.g042ed3e048af

Comments

David Gibson Jan. 21, 2021, 12:44 a.m. UTC | #1
On Wed, Jan 20, 2021 at 12:36:45PM +0530, Viresh Kumar wrote:
> This was copied from external DTC repository long back and isn't used

> anymore. Over that the dtc tool can be used to generate the dts source

> back from the dtb. Remove the unused fdtdump.c file.

> 

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>


Doesn't this make updating the kernel dtc from upstream needlessly
more difficult?

> ---

>  scripts/dtc/fdtdump.c | 163 ------------------------------------------

>  1 file changed, 163 deletions(-)

>  delete mode 100644 scripts/dtc/fdtdump.c

> 

> diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c

> deleted file mode 100644

> index 7d460a50b513..000000000000

> --- a/scripts/dtc/fdtdump.c

> +++ /dev/null

> @@ -1,163 +0,0 @@

> -// SPDX-License-Identifier: GPL-2.0

> -/*

> - * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>

> - */

> -

> -#include <stdint.h>

> -#include <stdio.h>

> -#include <stdlib.h>

> -#include <string.h>

> -#include <ctype.h>

> -

> -#include <fdt.h>

> -#include <libfdt_env.h>

> -

> -#include "util.h"

> -

> -#define ALIGN(x, a)	(((x) + ((a) - 1)) & ~((a) - 1))

> -#define PALIGN(p, a)	((void *)(ALIGN((unsigned long)(p), (a))))

> -#define GET_CELL(p)	(p += 4, *((const uint32_t *)(p-4)))

> -

> -static void print_data(const char *data, int len)

> -{

> -	int i;

> -	const char *p = data;

> -

> -	/* no data, don't print */

> -	if (len == 0)

> -		return;

> -

> -	if (util_is_printable_string(data, len)) {

> -		printf(" = \"%s\"", (const char *)data);

> -	} else if ((len % 4) == 0) {

> -		printf(" = <");

> -		for (i = 0; i < len; i += 4)

> -			printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)),

> -			       i < (len - 4) ? " " : "");

> -		printf(">");

> -	} else {

> -		printf(" = [");

> -		for (i = 0; i < len; i++)

> -			printf("%02x%s", *p++, i < len - 1 ? " " : "");

> -		printf("]");

> -	}

> -}

> -

> -static void dump_blob(void *blob)

> -{

> -	struct fdt_header *bph = blob;

> -	uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap);

> -	uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct);

> -	uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings);

> -	struct fdt_reserve_entry *p_rsvmap =

> -		(struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap);

> -	const char *p_struct = (const char *)blob + off_dt;

> -	const char *p_strings = (const char *)blob + off_str;

> -	uint32_t version = fdt32_to_cpu(bph->version);

> -	uint32_t totalsize = fdt32_to_cpu(bph->totalsize);

> -	uint32_t tag;

> -	const char *p, *s, *t;

> -	int depth, sz, shift;

> -	int i;

> -	uint64_t addr, size;

> -

> -	depth = 0;

> -	shift = 4;

> -

> -	printf("/dts-v1/;\n");

> -	printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic));

> -	printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize);

> -	printf("// off_dt_struct:\t0x%x\n", off_dt);

> -	printf("// off_dt_strings:\t0x%x\n", off_str);

> -	printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap);

> -	printf("// version:\t\t%d\n", version);

> -	printf("// last_comp_version:\t%d\n",

> -	       fdt32_to_cpu(bph->last_comp_version));

> -	if (version >= 2)

> -		printf("// boot_cpuid_phys:\t0x%x\n",

> -		       fdt32_to_cpu(bph->boot_cpuid_phys));

> -

> -	if (version >= 3)

> -		printf("// size_dt_strings:\t0x%x\n",

> -		       fdt32_to_cpu(bph->size_dt_strings));

> -	if (version >= 17)

> -		printf("// size_dt_struct:\t0x%x\n",

> -		       fdt32_to_cpu(bph->size_dt_struct));

> -	printf("\n");

> -

> -	for (i = 0; ; i++) {

> -		addr = fdt64_to_cpu(p_rsvmap[i].address);

> -		size = fdt64_to_cpu(p_rsvmap[i].size);

> -		if (addr == 0 && size == 0)

> -			break;

> -

> -		printf("/memreserve/ %llx %llx;\n",

> -		       (unsigned long long)addr, (unsigned long long)size);

> -	}

> -

> -	p = p_struct;

> -	while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {

> -

> -		/* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */

> -

> -		if (tag == FDT_BEGIN_NODE) {

> -			s = p;

> -			p = PALIGN(p + strlen(s) + 1, 4);

> -

> -			if (*s == '\0')

> -				s = "/";

> -

> -			printf("%*s%s {\n", depth * shift, "", s);

> -

> -			depth++;

> -			continue;

> -		}

> -

> -		if (tag == FDT_END_NODE) {

> -			depth--;

> -

> -			printf("%*s};\n", depth * shift, "");

> -			continue;

> -		}

> -

> -		if (tag == FDT_NOP) {

> -			printf("%*s// [NOP]\n", depth * shift, "");

> -			continue;

> -		}

> -

> -		if (tag != FDT_PROP) {

> -			fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag);

> -			break;

> -		}

> -		sz = fdt32_to_cpu(GET_CELL(p));

> -		s = p_strings + fdt32_to_cpu(GET_CELL(p));

> -		if (version < 16 && sz >= 8)

> -			p = PALIGN(p, 8);

> -		t = p;

> -

> -		p = PALIGN(p + sz, 4);

> -

> -		printf("%*s%s", depth * shift, "", s);

> -		print_data(t, sz);

> -		printf(";\n");

> -	}

> -}

> -

> -

> -int main(int argc, char *argv[])

> -{

> -	char *buf;

> -

> -	if (argc < 2) {

> -		fprintf(stderr, "supply input filename\n");

> -		return 5;

> -	}

> -

> -	buf = utilfdt_read(argv[1]);

> -	if (buf)

> -		dump_blob(buf);

> -	else

> -		return 10;

> -

> -	return 0;

> -}


-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Viresh Kumar Jan. 21, 2021, 4:17 a.m. UTC | #2
On 21-01-21, 11:44, David Gibson wrote:
> On Wed, Jan 20, 2021 at 12:36:45PM +0530, Viresh Kumar wrote:

> > This was copied from external DTC repository long back and isn't used

> > anymore. Over that the dtc tool can be used to generate the dts source

> > back from the dtb. Remove the unused fdtdump.c file.

> > 

> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

> 

> Doesn't this make updating the kernel dtc from upstream needlessly

> more difficult?


Hmm, I am not sure I understand the concern well. The kernel keeps a
list of files[1] it needs to automatically copy (using a script) from
the upstream dtc repo and fdtdump.c was never part of that. Keeping it
there isn't going to make any difficulty I believe.

-- 
viresh

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/dtc/update-dtc-source.sh
David Gibson Jan. 21, 2021, 6:26 a.m. UTC | #3
On Thu, Jan 21, 2021 at 09:47:57AM +0530, Viresh Kumar wrote:
> On 21-01-21, 11:44, David Gibson wrote:

> > On Wed, Jan 20, 2021 at 12:36:45PM +0530, Viresh Kumar wrote:

> > > This was copied from external DTC repository long back and isn't used

> > > anymore. Over that the dtc tool can be used to generate the dts source

> > > back from the dtb. Remove the unused fdtdump.c file.

> > > 

> > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

> > 

> > Doesn't this make updating the kernel dtc from upstream needlessly

> > more difficult?

> 

> Hmm, I am not sure I understand the concern well. The kernel keeps a

> list of files[1] it needs to automatically copy (using a script) from

> the upstream dtc repo and fdtdump.c was never part of that. Keeping it

> there isn't going to make any difficulty I believe.


Hm, ok.  Seems a bit clunky compared to embedding the whole directory,
but whatever.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Rob Herring Jan. 21, 2021, 2:18 p.m. UTC | #4
On Thu, Jan 21, 2021 at 12:43 AM David Gibson
<david@gibson.dropbear.id.au> wrote:
>

> On Thu, Jan 21, 2021 at 09:47:57AM +0530, Viresh Kumar wrote:

> > On 21-01-21, 11:44, David Gibson wrote:

> > > On Wed, Jan 20, 2021 at 12:36:45PM +0530, Viresh Kumar wrote:

> > > > This was copied from external DTC repository long back and isn't used

> > > > anymore. Over that the dtc tool can be used to generate the dts source

> > > > back from the dtb. Remove the unused fdtdump.c file.

> > > >

> > > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

> > >

> > > Doesn't this make updating the kernel dtc from upstream needlessly

> > > more difficult?

> >

> > Hmm, I am not sure I understand the concern well. The kernel keeps a

> > list of files[1] it needs to automatically copy (using a script) from

> > the upstream dtc repo and fdtdump.c was never part of that. Keeping it

> > there isn't going to make any difficulty I believe.

>

> Hm, ok.  Seems a bit clunky compared to embedding the whole directory,

> but whatever.


Either way, it's a list of what to keep or what to omit as we don't
want build files nor tests. If we were to take the whole thing, then
we should do a submodule, but so far no one wants submodules in the
kernel tree. There is a git subtree feature now that could do the same
thing as the script. But the script is good enough only needing small
tweaks occasionally, and anything else is work.

Rob
diff mbox series

Patch

diff --git a/scripts/dtc/fdtdump.c b/scripts/dtc/fdtdump.c
deleted file mode 100644
index 7d460a50b513..000000000000
--- a/scripts/dtc/fdtdump.c
+++ /dev/null
@@ -1,163 +0,0 @@ 
-// SPDX-License-Identifier: GPL-2.0
-/*
- * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com>
- */
-
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <fdt.h>
-#include <libfdt_env.h>
-
-#include "util.h"
-
-#define ALIGN(x, a)	(((x) + ((a) - 1)) & ~((a) - 1))
-#define PALIGN(p, a)	((void *)(ALIGN((unsigned long)(p), (a))))
-#define GET_CELL(p)	(p += 4, *((const uint32_t *)(p-4)))
-
-static void print_data(const char *data, int len)
-{
-	int i;
-	const char *p = data;
-
-	/* no data, don't print */
-	if (len == 0)
-		return;
-
-	if (util_is_printable_string(data, len)) {
-		printf(" = \"%s\"", (const char *)data);
-	} else if ((len % 4) == 0) {
-		printf(" = <");
-		for (i = 0; i < len; i += 4)
-			printf("0x%08x%s", fdt32_to_cpu(GET_CELL(p)),
-			       i < (len - 4) ? " " : "");
-		printf(">");
-	} else {
-		printf(" = [");
-		for (i = 0; i < len; i++)
-			printf("%02x%s", *p++, i < len - 1 ? " " : "");
-		printf("]");
-	}
-}
-
-static void dump_blob(void *blob)
-{
-	struct fdt_header *bph = blob;
-	uint32_t off_mem_rsvmap = fdt32_to_cpu(bph->off_mem_rsvmap);
-	uint32_t off_dt = fdt32_to_cpu(bph->off_dt_struct);
-	uint32_t off_str = fdt32_to_cpu(bph->off_dt_strings);
-	struct fdt_reserve_entry *p_rsvmap =
-		(struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap);
-	const char *p_struct = (const char *)blob + off_dt;
-	const char *p_strings = (const char *)blob + off_str;
-	uint32_t version = fdt32_to_cpu(bph->version);
-	uint32_t totalsize = fdt32_to_cpu(bph->totalsize);
-	uint32_t tag;
-	const char *p, *s, *t;
-	int depth, sz, shift;
-	int i;
-	uint64_t addr, size;
-
-	depth = 0;
-	shift = 4;
-
-	printf("/dts-v1/;\n");
-	printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic));
-	printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize);
-	printf("// off_dt_struct:\t0x%x\n", off_dt);
-	printf("// off_dt_strings:\t0x%x\n", off_str);
-	printf("// off_mem_rsvmap:\t0x%x\n", off_mem_rsvmap);
-	printf("// version:\t\t%d\n", version);
-	printf("// last_comp_version:\t%d\n",
-	       fdt32_to_cpu(bph->last_comp_version));
-	if (version >= 2)
-		printf("// boot_cpuid_phys:\t0x%x\n",
-		       fdt32_to_cpu(bph->boot_cpuid_phys));
-
-	if (version >= 3)
-		printf("// size_dt_strings:\t0x%x\n",
-		       fdt32_to_cpu(bph->size_dt_strings));
-	if (version >= 17)
-		printf("// size_dt_struct:\t0x%x\n",
-		       fdt32_to_cpu(bph->size_dt_struct));
-	printf("\n");
-
-	for (i = 0; ; i++) {
-		addr = fdt64_to_cpu(p_rsvmap[i].address);
-		size = fdt64_to_cpu(p_rsvmap[i].size);
-		if (addr == 0 && size == 0)
-			break;
-
-		printf("/memreserve/ %llx %llx;\n",
-		       (unsigned long long)addr, (unsigned long long)size);
-	}
-
-	p = p_struct;
-	while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {
-
-		/* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */
-
-		if (tag == FDT_BEGIN_NODE) {
-			s = p;
-			p = PALIGN(p + strlen(s) + 1, 4);
-
-			if (*s == '\0')
-				s = "/";
-
-			printf("%*s%s {\n", depth * shift, "", s);
-
-			depth++;
-			continue;
-		}
-
-		if (tag == FDT_END_NODE) {
-			depth--;
-
-			printf("%*s};\n", depth * shift, "");
-			continue;
-		}
-
-		if (tag == FDT_NOP) {
-			printf("%*s// [NOP]\n", depth * shift, "");
-			continue;
-		}
-
-		if (tag != FDT_PROP) {
-			fprintf(stderr, "%*s ** Unknown tag 0x%08x\n", depth * shift, "", tag);
-			break;
-		}
-		sz = fdt32_to_cpu(GET_CELL(p));
-		s = p_strings + fdt32_to_cpu(GET_CELL(p));
-		if (version < 16 && sz >= 8)
-			p = PALIGN(p, 8);
-		t = p;
-
-		p = PALIGN(p + sz, 4);
-
-		printf("%*s%s", depth * shift, "", s);
-		print_data(t, sz);
-		printf(";\n");
-	}
-}
-
-
-int main(int argc, char *argv[])
-{
-	char *buf;
-
-	if (argc < 2) {
-		fprintf(stderr, "supply input filename\n");
-		return 5;
-	}
-
-	buf = utilfdt_read(argv[1]);
-	if (buf)
-		dump_blob(buf);
-	else
-		return 10;
-
-	return 0;
-}