summaryrefslogtreecommitdiff
path: root/dtc.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-11-22 14:39:23 +1100
committerJon Loeliger <jdl@freescale.com>2007-11-26 16:00:19 -0600
commitdc941774e228779562379a221ddc489d289e8513 (patch)
treee90a244560f8ca8e1ffd8393f3c3ab74e420d37a /dtc.h
parentb16a2bd89dbf109b9c8d1c9e047b9afa72af6d2f (diff)
downloaddtc-dc941774e228779562379a221ddc489d289e8513.tar.gz
dtc: Merge refs and labels into single "markers" list (v2)
Currently, every 'data' object, used to represent property values, has two lists of fixup structures - one for labels and one for references. Sometimes we want to look at them separately, but other times we need to consider both types of fixup. I'm planning to implement string references, where a full path rather than a phandle is substituted into a property value. Adding yet another list of fixups for that would start to get silly. So, this patch merges the "refs" and "labels" lists into a single list of "markers", each of which has a type field indicating if it represents a label or a phandle reference. String references or any other new type of in-data marker will then just need a new type value - merging data blocks and other common manipulations will just work. While I was at it I made some cleanups to the handling of fixups which simplify things further. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.h')
-rw-r--r--dtc.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/dtc.h b/dtc.h
index ac3657b..ad21e0d 100644
--- a/dtc.h
+++ b/dtc.h
@@ -101,23 +101,34 @@ typedef u32 cell_t;
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Data blobs */
-struct fixup {
+enum markertype {
+ REF_PHANDLE,
+ LABEL,
+};
+
+struct marker {
+ enum markertype type;
int offset;
char *ref;
- struct fixup *next;
+ struct marker *next;
};
struct data {
int len;
char *val;
int asize;
- struct fixup *refs;
- struct fixup *labels;
+ struct marker *markers;
};
+
#define empty_data ((struct data){ /* all .members = 0 or NULL */ })
-void fixup_free(struct fixup *f);
+#define for_each_marker(m) \
+ for (; (m); (m) = (m)->next)
+#define for_each_marker_of_type(m, t) \
+ for_each_marker(m) \
+ if ((m)->type == (t))
+
void data_free(struct data d);
struct data data_grow_for(struct data d, int xlen);
@@ -135,8 +146,7 @@ struct data data_append_byte(struct data d, uint8_t byte);
struct data data_append_zeroes(struct data d, int len);
struct data data_append_align(struct data d, int align);
-struct data data_add_fixup(struct data d, char *ref);
-struct data data_add_label(struct data d, char *label);
+struct data data_add_marker(struct data d, enum markertype type, char *ref);
int data_is_one_string(struct data d);