From: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Devicetree Discuss
<devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org>
Subject: [PATCH v2 2/6] ftdump: use util_read_fdt
Date: Wed, 7 Sep 2011 12:54:16 -0700 [thread overview]
Message-ID: <1315425260-2711-3-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1315425260-2711-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Now that we have this function, ftdump should use it too.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Makefile | 2 +-
Makefile.ftdump | 3 ++-
ftdump.c | 33 +++++----------------------------
3 files changed, 8 insertions(+), 30 deletions(-)
diff --git a/Makefile b/Makefile
index 2172d9a..0baada5 100644
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,7 @@ convert-dtsv0: $(CONVERT_OBJS)
@$(VECHO) LD $@
$(LINK.c) -o $@ $^
-ftdump: $(FTDUMP_OBJS)
+ftdump: $(FTDUMP_OBJS) $(LIBFDT_archive)
#
diff --git a/Makefile.ftdump b/Makefile.ftdump
index 2744a18..dc3a2c1 100644
--- a/Makefile.ftdump
+++ b/Makefile.ftdump
@@ -6,7 +6,8 @@
FTDUMP_SRCS = \
ftdump.c \
- util.c
+ util.c \
+ utilfdt.c
FTDUMP_GEN_SRCS =
diff --git a/ftdump.c b/ftdump.c
index db932e3..43c09c0 100644
--- a/ftdump.c
+++ b/ftdump.c
@@ -12,8 +12,7 @@
#include <libfdt_env.h>
#include "util.h"
-
-#define FTDUMP_BUF_SIZE 65536
+#include "utilfdt.h"
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
@@ -147,40 +146,18 @@ static void dump_blob(void *blob)
int main(int argc, char *argv[])
{
- FILE *fp;
char *buf;
- int size;
if (argc < 2) {
fprintf(stderr, "supply input filename\n");
return 5;
}
- if (strcmp(argv[1], "-") == 0) {
- fp = stdin;
- } else {
- fp = fopen(argv[1], "rb");
- if (fp == NULL) {
- fprintf(stderr, "unable to open %s\n", argv[1]);
- return 10;
- }
- }
-
- buf = malloc(FTDUMP_BUF_SIZE);
- if (!buf) {
- fprintf(stderr, "Couldn't allocate %d byte buffer\n", FTDUMP_BUF_SIZE);
+ buf = util_read_fdt(argv[1]);
+ if (buf)
+ dump_blob(buf);
+ else
return 10;
- }
-
- size = fread(buf, 1, FTDUMP_BUF_SIZE, fp);
- if (size == FTDUMP_BUF_SIZE) {
- fprintf(stderr, "file too large (maximum is %d bytes)\n", FTDUMP_BUF_SIZE);
- return 10;
- }
-
- dump_blob(buf);
-
- fclose(fp);
return 0;
}
--
1.7.3.1
next prev parent reply other threads:[~2011-09-07 19:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 19:54 [PATCH v2 0/6] Add fdtget and fdtput for access to fdt from build system Simon Glass
[not found] ` <1315425260-2711-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-07 19:54 ` [PATCH v2 1/6] Add utilfdt for common functions Simon Glass
[not found] ` <1315425260-2711-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:20 ` David Gibson
[not found] ` <20110908052028.GQ30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:37 ` Simon Glass
[not found] ` <CAPnjgZ1J0k93vo1A5ns5OxW5=nesr9pwLMMPAc+gyaOWmtmwuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-09 2:34 ` David Gibson
2011-09-07 19:54 ` Simon Glass [this message]
2011-09-07 19:54 ` [PATCH v2 3/6] Add fdtget utility to read property values from device tree Simon Glass
[not found] ` <1315425260-2711-4-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:25 ` David Gibson
[not found] ` <20110908052547.GR30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:47 ` Simon Glass
[not found] ` <CAPnjgZ0qnr8VVOX7kCq6wEZ-OxAsxmHkPcTGE7wu1B_9ME_SPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-09 4:49 ` David Gibson
[not found] ` <20110909044945.GF21002-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-09 5:44 ` Simon Glass
[not found] ` <CAPnjgZ3xw7ByV4Yzeot3zgs4oo0zciX2OV_V4vfQ8tGsgLcPvw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-12 0:53 ` David Gibson
[not found] ` <20110912005357.GI9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-12 4:34 ` Simon Glass
[not found] ` <CAPnjgZ1vevcwCQU+uyjAA3YZd--RhU9MgAF8O8G4Hr5e4CYo_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-16 8:18 ` David Gibson
[not found] ` <20110916081804.GF9025-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-16 16:25 ` Simon Glass
[not found] ` <CAPnjgZ1LUPm9mRft5q=KHGe2h2+Masdh0kGXQ-7j1VTUDsMP7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 2:04 ` David Gibson
[not found] ` <20110919020440.GA15001-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 5:46 ` Simon Glass
[not found] ` <CAPnjgZ09mO06uruZtC=86BuitUWtQkGQfaHTf25HXK9KzoiD+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-19 8:05 ` David Gibson
[not found] ` <20110919080557.GA29197-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-19 15:11 ` Simon Glass
2011-09-07 19:54 ` [PATCH v2 4/6] fdtget: Add basic tests Simon Glass
[not found] ` <1315425260-2711-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:27 ` David Gibson
2011-09-07 19:54 ` [PATCH v2 5/6] Add new fdtput utility to write values to fdt Simon Glass
[not found] ` <1315425260-2711-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:32 ` David Gibson
[not found] ` <20110908053209.GT30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:51 ` Simon Glass
[not found] ` <CAPnjgZ2UNjxTz9=sWJ8JFq=AXF1NS4dG6C_BkyHvfDf=ZMVpmg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-08 13:00 ` David Gibson
2011-09-07 19:54 ` [PATCH v2 6/6] fdtput: Add basic tests Simon Glass
[not found] ` <1315425260-2711-7-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-09-08 5:32 ` David Gibson
[not found] ` <20110908053235.GU30278-787xzQ0H9iQXU02nzanrWNbf9cGiqdzd@public.gmane.org>
2011-09-08 12:55 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315425260-2711-3-git-send-email-sjg@chromium.org \
--to=sjg-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).