From cd296721a9645f9f28800a072490fa15458d1fb7 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Fri, 28 Sep 2012 21:25:59 +0000 Subject: dtc: import latest upstream dtc This updates scripts/dtc to commit 317a5d9 "dtc: zero out new label objects" from git://git.jdl.com/software/dtc.git. This adds features such as: * /bits/ syntax for cell data. * Math expressions within cell data. * The ability to delete properties or nodes. * Support for #line directives in the input file, which allows the use of cpp on *.dts. * -i command-line option (/include/ path) * -W/-E command-line options for error/warning control. * Removal of spew to STDOUT containing the filename being compiled. * Many additions to the libfdt API. Signed-off-by: Stephen Warren Acked-by: Jon Loeliger Signed-off-by: Rob Herring --- scripts/dtc/dtc.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'scripts/dtc/dtc.h') diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index f37c97eb3dfc..d501c8605f26 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m, const void *p, int len); struct data data_merge(struct data d1, struct data d2); struct data data_append_cell(struct data d, cell_t word); +struct data data_append_integer(struct data d, uint64_t word, int bits); struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); struct data data_append_addr(struct data d, uint64_t addr); struct data data_append_byte(struct data d, uint8_t byte); @@ -126,11 +128,13 @@ int data_is_one_string(struct data d); /* Live trees */ struct label { + int deleted; char *label; struct label *next; }; struct property { + int deleted; char *name; struct data val; @@ -140,6 +144,7 @@ struct property { }; struct node { + int deleted; char *name; struct property *proplist; struct node *children; @@ -156,28 +161,71 @@ struct node { struct label *labels; }; +static inline struct label *for_each_label_next(struct label *l) +{ + do { + l = l->next; + } while (l && l->deleted); + + return l; +} + #define for_each_label(l0, l) \ + for ((l) = (l0); (l); (l) = for_each_label_next(l)) + +#define for_each_label_withdel(l0, l) \ for ((l) = (l0); (l); (l) = (l)->next) +static inline struct property *for_each_property_next(struct property *p) +{ + do { + p = p->next; + } while (p && p->deleted); + + return p; +} + #define for_each_property(n, p) \ + for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p)) + +#define for_each_property_withdel(n, p) \ for ((p) = (n)->proplist; (p); (p) = (p)->next) -#define for_each_child(n, c) \ +static inline struct node *for_each_child_next(struct node *c) +{ + do { + c = c->next_sibling; + } while (c && c->deleted); + + return c; +} + +#define for_each_child(n, c) \ + for ((c) = (n)->children; (c); (c) = for_each_child_next(c)) + +#define for_each_child_withdel(n, c) \ for ((c) = (n)->children; (c); (c) = (c)->next_sibling) void add_label(struct label **labels, char *label); +void delete_labels(struct label **labels); struct property *build_property(char *name, struct data val); +struct property *build_property_delete(char *name); 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 *build_node_delete(void); struct node *name_node(struct node *node, char *name); struct node *chain_node(struct node *first, struct node *list); struct node *merge_nodes(struct node *old_node, struct node *new_node); void add_property(struct node *node, struct property *prop); +void delete_property_by_name(struct node *node, char *name); +void delete_property(struct property *prop); void add_child(struct node *parent, struct node *child); +void delete_node_by_name(struct node *parent, char *name); +void delete_node(struct node *node); const char *get_unitname(struct node *node); struct property *get_property(struct node *node, const char *propname); @@ -224,6 +272,7 @@ void sort_tree(struct boot_info *bi); /* Checks */ +void parse_checks_option(bool warn, bool error, const char *optarg); void process_checks(int force, struct boot_info *bi); /* Flattened trees */ -- cgit v1.2.3 From 205a8eb7ce713c7f1722297dd97d19dcea6f266c Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 8 Oct 2012 16:15:26 -0600 Subject: dtc: fix for_each_*() to skip first object if deleted The previous definition of for_each_*() would always include the very first object within the list, irrespective of whether it was marked deleted, since the deleted flag was not checked on the first object, but only on any "next" object. Fix for_each_*() to check the deleted flag in the loop body every iteration to correct this. (upstream dtc commit 1762ab42ef77db7ab2776d0d6cba3515150f518a) Signed-off-by: Stephen Warren Signed-off-by: Rob Herring --- scripts/dtc/dtc.h | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) (limited to 'scripts/dtc/dtc.h') diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index d501c8605f26..3e42a071070e 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h @@ -161,51 +161,27 @@ struct node { struct label *labels; }; -static inline struct label *for_each_label_next(struct label *l) -{ - do { - l = l->next; - } while (l && l->deleted); - - return l; -} - -#define for_each_label(l0, l) \ - for ((l) = (l0); (l); (l) = for_each_label_next(l)) - #define for_each_label_withdel(l0, l) \ for ((l) = (l0); (l); (l) = (l)->next) -static inline struct property *for_each_property_next(struct property *p) -{ - do { - p = p->next; - } while (p && p->deleted); - - return p; -} - -#define for_each_property(n, p) \ - for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p)) +#define for_each_label(l0, l) \ + for_each_label_withdel(l0, l) \ + if (!(l)->deleted) #define for_each_property_withdel(n, p) \ for ((p) = (n)->proplist; (p); (p) = (p)->next) -static inline struct node *for_each_child_next(struct node *c) -{ - do { - c = c->next_sibling; - } while (c && c->deleted); - - return c; -} - -#define for_each_child(n, c) \ - for ((c) = (n)->children; (c); (c) = for_each_child_next(c)) +#define for_each_property(n, p) \ + for_each_property_withdel(n, p) \ + if (!(p)->deleted) #define for_each_child_withdel(n, c) \ for ((c) = (n)->children; (c); (c) = (c)->next_sibling) +#define for_each_child(n, c) \ + for_each_child_withdel(n, c) \ + if (!(c)->deleted) + void add_label(struct label **labels, char *label); void delete_labels(struct label **labels); -- cgit v1.2.3