summaryrefslogtreecommitdiff
path: root/dtc.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2010-11-10 09:51:09 +1100
committerJon Loeliger <jdl@jdl.com>2010-11-13 15:47:29 -0600
commit37c0b6a0916c31a5eae0a9ddfcc5d0b8fb4569c6 (patch)
tree26035a19464d9a564939f0ad9ac360f5ae005506 /dtc.c
parent73ae43ea44a40c2ac00dd94523f270177a1e72e9 (diff)
downloaddtc-37c0b6a0916c31a5eae0a9ddfcc5d0b8fb4569c6.tar.gz
dtc: Add code to make diffing trees easier
This patch adds a "dtdiff" script to do a useful form diff of two device trees. This automatically converts the tree to dts form (if it's not already) and uses a new "-s" option in dtc to "sort" the tree. That is, it sorts the reserve entries, it sorts the properties within each node by name, and it sorts nodes by name within their parent. This gives a pretty sensible diff between the trees, which will ignore semantically null internal rearrangements (directly diffing the dts files can give a lot of noise due to the order changes). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.c')
-rw-r--r--dtc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/dtc.c b/dtc.c
index 8b31d20..cbc0193 100644
--- a/dtc.c
+++ b/dtc.c
@@ -81,6 +81,8 @@ static void __attribute__ ((noreturn)) usage(void)
fprintf(stderr, "\t\tSet the physical boot cpu\n");
fprintf(stderr, "\t-f\n");
fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
+ fprintf(stderr, "\t-s\n");
+ fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
fprintf(stderr, "\t-v\n");
fprintf(stderr, "\t\tPrint DTC version and exit\n");
fprintf(stderr, "\t-H <phandle format>\n");
@@ -97,7 +99,7 @@ int main(int argc, char *argv[])
const char *inform = "dts";
const char *outform = "dts";
const char *outname = "-";
- int force = 0, check = 0;
+ int force = 0, check = 0, sort = 0;
const char *arg;
int opt;
FILE *outf = NULL;
@@ -109,7 +111,7 @@ int main(int argc, char *argv[])
minsize = 0;
padsize = 0;
- while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:")) != EOF) {
+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
switch (opt) {
case 'I':
inform = optarg;
@@ -159,6 +161,10 @@ int main(int argc, char *argv[])
optarg);
break;
+ case 's':
+ sort = 1;
+ break;
+
case 'h':
default:
usage();
@@ -197,6 +203,8 @@ int main(int argc, char *argv[])
fill_fullpaths(bi->dt, "");
process_checks(force, bi);
+ if (sort)
+ sort_tree(bi);
if (streq(outname, "-")) {
outf = stdout;