From 05898c67c15d73fe50bd87fc939bd9ee6a4275ce Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 24 Feb 2010 18:22:17 +1100 Subject: dtc: Allow multiple labels on nodes and properties At present, both the grammar and our internal data structures mean that there can be only one label on a node or property. This is a fairly arbitrary constraint, given that any number of value labels can appear at the same point, and that in C you can have any number of labels on the same statement. This is pretty much a non-issue now, but it may become important with some of the extensions that Grant and I have in mind. It's not that hard to change, so this patch does so, allowing an arbitrary number of labels on any given node or property. As usual a testcase is added too. Signed-off-by: David Gibson Acked-by: Grant Likely --- dtc.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'dtc.h') diff --git a/dtc.h b/dtc.h index 5367198..6d61b6d 100644 --- a/dtc.h +++ b/dtc.h @@ -125,13 +125,18 @@ int data_is_one_string(struct data d); #define MAX_NODENAME_LEN 31 /* Live trees */ +struct label { + char *label; + struct label *next; +}; + struct property { char *name; struct data val; struct property *next; - char *label; + struct label *labels; }; struct node { @@ -148,21 +153,26 @@ struct node { cell_t phandle; int addr_cells, size_cells; - char *label; + struct label *labels; }; +#define for_each_label(l0, l) \ + for ((l) = (l0); (l); (l) = (l)->next) + #define for_each_property(n, p) \ for ((p) = (n)->proplist; (p); (p) = (p)->next) #define for_each_child(n, c) \ for ((c) = (n)->children; (c); (c) = (c)->next_sibling) -struct property *build_property(char *name, struct data val, char *label); +void add_label(struct label **labels, char *label); + +struct property *build_property(char *name, struct data val); struct property *chain_property(struct property *first, struct property *list); struct property *reverse_properties(struct property *first); struct node *build_node(struct property *proplist, struct node *children); -struct node *name_node(struct node *node, char *name, char *label); +struct node *name_node(struct node *node, char *name); struct node *chain_node(struct node *first, struct node *list); void add_property(struct node *node, struct property *prop); @@ -191,10 +201,10 @@ struct reserve_info { struct reserve_info *next; - char *label; + struct label *labels; }; -struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len, char *label); +struct reserve_info *build_reserve_entry(uint64_t start, uint64_t len); struct reserve_info *chain_reserve_entry(struct reserve_info *first, struct reserve_info *list); struct reserve_info *add_reserve_entry(struct reserve_info *list, -- cgit v1.2.1