summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/dtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dtc/dtc.c')
-rw-r--r--scripts/dtc/dtc.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index d8fd43b..cbc0193 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -30,30 +30,7 @@ int quiet; /* Level of quietness */
int reservenum; /* Number of memory reservation slots */
int minsize; /* Minimum blob size */
int padsize; /* Additional padding to blob */
-
-char *join_path(const char *path, const char *name)
-{
- int lenp = strlen(path);
- int lenn = strlen(name);
- int len;
- int needslash = 1;
- char *str;
-
- len = lenp + lenn + 2;
- if ((lenp > 0) && (path[lenp-1] == '/')) {
- needslash = 0;
- len--;
- }
-
- str = xmalloc(len);
- memcpy(str, path, lenp);
- if (needslash) {
- str[lenp] = '/';
- lenp++;
- }
- memcpy(str+lenp, name, lenn+1);
- return str;
-}
+int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
static void fill_fullpaths(struct node *tree, const char *prefix)
{
@@ -104,8 +81,15 @@ 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");
+ fprintf(stderr, "\t\tphandle formats are:\n");
+ fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
+ fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
+ fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
exit(3);
}
@@ -115,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;
@@ -127,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:v")) != EOF) {
+ while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
switch (opt) {
case 'I':
inform = optarg;
@@ -165,6 +149,22 @@ int main(int argc, char *argv[])
case 'v':
printf("Version: %s\n", DTC_VERSION);
exit(0);
+ case 'H':
+ if (streq(optarg, "legacy"))
+ phandle_format = PHANDLE_LEGACY;
+ else if (streq(optarg, "epapr"))
+ phandle_format = PHANDLE_EPAPR;
+ else if (streq(optarg, "both"))
+ phandle_format = PHANDLE_BOTH;
+ else
+ die("Invalid argument \"%s\" to -H option\n",
+ optarg);
+ break;
+
+ case 's':
+ sort = 1;
+ break;
+
case 'h':
default:
usage();
@@ -182,6 +182,9 @@ int main(int argc, char *argv[])
if (minsize && padsize)
die("Can't set both -p and -S\n");
+ if (minsize)
+ fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
+
fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
inform, outform, arg);
@@ -200,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;
OpenPOWER on IntegriCloud