aboutsummaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-02-07 16:37:50 +1100
committerJon Loeliger <jdl@freescale.com>2007-02-08 17:26:41 -0600
commit32da475af165a0e1e274aa9a8bbdfb873831efa7 (patch)
treeb5e16c13805db07b410c543f0443daeb2c688e54 /data.c
parent54382390e40654957e16da7ba48ee86822ffe590 (diff)
downloaddtc-32da475af165a0e1e274aa9a8bbdfb873831efa7.zip
dtc-32da475af165a0e1e274aa9a8bbdfb873831efa7.tar.gz
dtc-32da475af165a0e1e274aa9a8bbdfb873831efa7.tar.bz2
Allow multipart property values
At present each property definition in a dts file must give as the value either a string ("abc..."), a bytestring ([12abcd...]) or a cell list (<1 2 3 ...>). This patch allows a property value to be given as several of these, comma-separated. The final property value is just the components appended together. So a property could have a list of cells followed by a string, or a bytestring followed by some cells. Cells are always aligned, so if cells are given following a string or bytestring which is not a multiple of 4 bytes long, zero bytes are inserted to align the following cells. The primary motivation for this feature, however, is to allow defining a property as a list of several strings. This is what's needed for defining OF 'compatible' properties, and is less ugly and fiddly than using embedded \0s in the strings. Signed-off-by: David Gibson <dwg@au1.ibm.com> Signed-off-by: Jon Loeliger <jdl@freescale.com>
Diffstat (limited to 'data.c')
-rw-r--r--data.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/data.c b/data.c
index d3b55f9..1907a1a 100644
--- a/data.c
+++ b/data.c
@@ -197,6 +197,33 @@ struct data data_append_data(struct data d, void *p, int len)
return d;
}
+struct data data_merge(struct data d1, struct data d2)
+{
+ struct data d;
+ struct fixup **ff;
+ struct fixup *f, *f2;
+
+ d = data_append_data(d1, d2.val, d2.len);
+
+ /* Extract d2's fixups */
+ f2 = d2.refs;
+ d2.refs = NULL;
+
+ /* Tack them onto d's list of fixups */
+ ff = &d.refs;
+ while (*ff)
+ ff = &((*ff)->next);
+ *ff = f2;
+
+ /* And correct them for their new position */
+ for (f = f2; f; f = f->next)
+ f->offset += d1.len;
+
+ data_free(d2);
+
+ return d;
+}
+
struct data data_append_cell(struct data d, cell_t word)
{
cell_t beword = cpu_to_be32(word);