Changeset f984d8f in rtems for cpukit/dtc


Ignore:
Timestamp:
Apr 1, 2017, 3:31:41 PM (3 years ago)
Author:
Simon Glass <sjg@…>
Branches:
master
Children:
903d2ec
Parents:
67f49b98
git-author:
Simon Glass <sjg@…> (04/01/17 15:31:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:10)
Message:

Add a libfdt function to write a property placeholder

The existing function to add a new property to a tree being built requires
that the entire contents of the new property be passed in. For some
applications it is more convenient to be able to add the property contents
later, perhaps by reading from a file. This avoids double-buffering of the
contents.

Add a new function to support this and adjust the existing fdt_property() to
use it.
Signed-off-by: Simon Glass <sjg@…>
Signed-off-by: David Gibson <david@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/dtc/libfdt/fdt_sw.c

    r67f49b98 rf984d8f  
    221221}
    222222
    223 int fdt_property(void *fdt, const char *name, const void *val, int len)
     223int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
    224224{
    225225        struct fdt_property *prop;
     
    239239        prop->nameoff = cpu_to_fdt32(nameoff);
    240240        prop->len = cpu_to_fdt32(len);
    241         memcpy(prop->data, val, len);
     241        *valp = prop->data;
     242        return 0;
     243}
     244
     245int fdt_property(void *fdt, const char *name, const void *val, int len)
     246{
     247        void *ptr;
     248        int ret;
     249
     250        ret = fdt_property_placeholder(fdt, name, len, &ptr);
     251        if (ret)
     252                return ret;
     253        memcpy(ptr, val, len);
    242254        return 0;
    243255}
Note: See TracChangeset for help on using the changeset viewer.