ftdump: use utilfdt to read blob
Now that we have utilfdt_read(), ftdump should use it too. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
1c25c0d520
commit
07a8691fbb
1 changed files with 4 additions and 28 deletions
32
ftdump.c
32
ftdump.c
|
@ -13,8 +13,6 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define FTDUMP_BUF_SIZE 65536
|
|
||||||
|
|
||||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||||
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
|
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
|
||||||
#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4)))
|
#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4)))
|
||||||
|
@ -147,40 +145,18 @@ static void dump_blob(void *blob)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp;
|
|
||||||
char *buf;
|
char *buf;
|
||||||
int size;
|
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "supply input filename\n");
|
fprintf(stderr, "supply input filename\n");
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[1], "-") == 0) {
|
buf = utilfdt_read(argv[1]);
|
||||||
fp = stdin;
|
if (buf)
|
||||||
} else {
|
dump_blob(buf);
|
||||||
fp = fopen(argv[1], "rb");
|
else
|
||||||
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);
|
|
||||||
return 10;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue