diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-10-18 17:22:30 +1000 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-10-22 09:53:15 -0500 |
commit | 169f0b183d45b87ba6dfc194792aee6170ffb54d (patch) | |
tree | d82f393d9df2ec05b823fc0de743b02d107b19cb /dtc.c | |
parent | 394e47208df7e3b22c089745695f41966d100f3e (diff) | |
download | dtc-169f0b183d45b87ba6dfc194792aee6170ffb54d.zip dtc-169f0b183d45b87ba6dfc194792aee6170ffb54d.tar.gz dtc-169f0b183d45b87ba6dfc194792aee6170ffb54d.tar.bz2 |
dtc: Disable semantic checks by default
At present, dtc makes a lot of semantic checks on the device tree by
default, and will refuse to produce output if they fail. This means
people tend to need -f to force output despite failing semantic checks
rather a lot.
This patch splits the device tree checks into structural checks (no
bad or duplicate names or phandles) and semantic checks (everything
else). By default, only the structural checks are performed, and are
fatal. -f will force output even with structural errors (using this
in -Idts mode would essentially always be a bad idea, but it might be
useful in -Idtb mode for examining a malformed dtb).
Semantic checks are only performed if the new -c command line option
is supplied, and are always warnings only. Semantic checks will never
be performed on a tree with structural errors.
This patch is only a stopgap before implementing proper fine-grained
error/warning handling, but it should at least get rid of the
far-too-frequent need for -f for the time being.
This patch removes the -f from the dtc testcases now that it's no
longer necessary.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.c')
-rw-r--r-- | dtc.c | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -112,19 +112,20 @@ int main(int argc, char *argv[]) char *inform = "dts"; char *outform = "dts"; char *outname = "-"; - int force = 0; + int force = 0, check = 0; char *arg; int opt; FILE *inf = NULL; FILE *outf = NULL; int outversion = DEFAULT_FDT_VERSION; int boot_cpuid_phys = 0xfeedbeef; + int structure_ok; quiet = 0; reservenum = 0; minsize = 0; - while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:fqb:v")) != EOF) { + while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:fcqb:v")) != EOF) { switch (opt) { case 'I': inform = optarg; @@ -147,6 +148,9 @@ int main(int argc, char *argv[]) case 'f': force = 1; break; + case 'c': + check = 1; + break; case 'q': quiet++; break; @@ -189,12 +193,25 @@ int main(int argc, char *argv[]) if (! bi || ! bi->dt) die("Couldn't read input tree\n"); - if (! check_device_tree(bi->dt, outversion, boot_cpuid_phys)) { - if ((force) && (quiet < 3)) - fprintf(stderr, "Input tree has errors, output forced\n"); - if (! force) { - fprintf(stderr, "Input tree has errors, not writing output (use -f to force output)\n"); + structure_ok = check_structure(bi->dt); + if (!structure_ok) { + if (!force) { + fprintf(stderr, "ERROR: Input tree has structural errors, aborting (use -f to force output)\n"); exit(1); + } else if (quiet < 3) { + fprintf(stderr, "Warning: Input tree has structural errors, output forced\n"); + } + } + + fixup_references(bi->dt); + + if (check) { + if (!structure_ok) { + fprintf(stderr, "Warning: Skipping semantic checks due to structural errors\n"); + } else { + if (!check_semantics(bi->dt, outversion, + boot_cpuid_phys)) + fprintf(stderr, "Warning: Input tree has semantic errors\n"); } } |