diff options
Diffstat (limited to 'scripts/dtc/treesource.c')
| -rw-r--r-- | scripts/dtc/treesource.c | 51 | 
1 files changed, 28 insertions, 23 deletions
diff --git a/scripts/dtc/treesource.c b/scripts/dtc/treesource.c index 1521ff11bb9..5740e6992d3 100644 --- a/scripts/dtc/treesource.c +++ b/scripts/dtc/treesource.c @@ -23,6 +23,7 @@  extern FILE *yyin;  extern int yyparse(void); +extern YYLTYPE yylloc;  struct boot_info *the_boot_info;  int treesource_error; @@ -32,8 +33,9 @@ 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; +	yylloc.file = current_srcfile;  	if (yyparse() != 0)  		die("Unable to parse input tree\n"); @@ -63,26 +65,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 +109,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 +237,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 +249,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 +270,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); @@ -275,4 +281,3 @@ void dt_to_source(FILE *f, struct boot_info *bi)  	write_tree_source_node(f, bi->dt, 0);  } -  | 
