summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/treesource.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dtc/treesource.c')
-rw-r--r--scripts/dtc/treesource.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c
index 1521ff11bb97..c09aafade313 100644
--- a/scripts/dtc/treesource.c
+++ b/scripts/dtc/treesource.c
@@ -32,8 +32,8 @@ struct boot_info *dt_from_source(const char *fname)
the_boot_info = NULL;
treesource_error = 0;
- srcpos_file = dtc_open_file(fname, NULL);
- yyin = srcpos_file->file;
+ srcfile_push(fname);
+ yyin = current_srcfile->f;
if (yyparse() != 0)
die("Unable to parse input tree\n");
@@ -63,26 +63,20 @@ static void write_propval_string(FILE *f, struct data val)
{
const char *str = val.val;
int i;
- int newchunk = 1;
struct marker *m = val.markers;
assert(str[val.len-1] == '\0');
+ while (m && (m->offset == 0)) {
+ if (m->type == LABEL)
+ fprintf(f, "%s: ", m->ref);
+ m = m->next;
+ }
+ fprintf(f, "\"");
+
for (i = 0; i < (val.len-1); i++) {
char c = str[i];
- if (newchunk) {
- while (m && (m->offset <= i)) {
- if (m->type == LABEL) {
- assert(m->offset == i);
- fprintf(f, "%s: ", m->ref);
- }
- m = m->next;
- }
- fprintf(f, "\"");
- newchunk = 0;
- }
-
switch (c) {
case '\a':
fprintf(f, "\\a");
@@ -113,7 +107,14 @@ static void write_propval_string(FILE *f, struct data val)
break;
case '\0':
fprintf(f, "\", ");
- newchunk = 1;
+ while (m && (m->offset < i)) {
+ if (m->type == LABEL) {
+ assert(m->offset == (i+1));
+ fprintf(f, "%s: ", m->ref);
+ }
+ m = m->next;
+ }
+ fprintf(f, "\"");
break;
default:
if (isprint(c))
@@ -234,10 +235,11 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
{
struct property *prop;
struct node *child;
+ struct label *l;
write_prefix(f, level);
- if (tree->label)
- fprintf(f, "%s: ", tree->label);
+ for_each_label(tree->labels, l)
+ fprintf(f, "%s: ", l->label);
if (tree->name && (*tree->name))
fprintf(f, "%s {\n", tree->name);
else
@@ -245,8 +247,8 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
for_each_property(tree, prop) {
write_prefix(f, level+1);
- if (prop->label)
- fprintf(f, "%s: ", prop->label);
+ for_each_label(prop->labels, l)
+ fprintf(f, "%s: ", l->label);
fprintf(f, "%s", prop->name);
write_propval(f, prop);
}
@@ -266,8 +268,10 @@ void dt_to_source(FILE *f, struct boot_info *bi)
fprintf(f, "/dts-v1/;\n\n");
for (re = bi->reservelist; re; re = re->next) {
- if (re->label)
- fprintf(f, "%s: ", re->label);
+ struct label *l;
+
+ for_each_label(re->labels, l)
+ fprintf(f, "%s: ", l->label);
fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n",
(unsigned long long)re->re.address,
(unsigned long long)re->re.size);
OpenPOWER on IntegriCloud