Changeset f984d8f in rtems


Ignore:
Timestamp:
Apr 1, 2017, 3:31:41 PM (2 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@…>

Location:
cpukit
Files:
2 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}
  • cpukit/include/libfdt.h

    r67f49b98 rf984d8f  
    13151315        return fdt_property_u32(fdt, name, val);
    13161316}
     1317
     1318/**
     1319 * fdt_property_placeholder - add a new property and return a ptr to its value
     1320 *
     1321 * @fdt: pointer to the device tree blob
     1322 * @name: name of property to add
     1323 * @len: length of property value in bytes
     1324 * @valp: returns a pointer to where where the value should be placed
     1325 *
     1326 * returns:
     1327 *      0, on success
     1328 *      -FDT_ERR_BADMAGIC,
     1329 *      -FDT_ERR_NOSPACE, standard meanings
     1330 */
     1331int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);
     1332
    13171333#define fdt_property_string(fdt, name, str) \
    13181334        fdt_property(fdt, name, str, strlen(str)+1)
Note: See TracChangeset for help on using the changeset viewer.