Changeset a1c3b41a in rtems


Ignore:
Timestamp:
Jul 27, 2017, 4:33:11 PM (2 years ago)
Author:
Pantelis Antoniou <pantelis.antoniou@…>
Branches:
master
Children:
f5e879f
Parents:
903d2ec
git-author:
Pantelis Antoniou <pantelis.antoniou@…> (07/27/17 16:33:11)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:11)
Message:

Introduce fdt_setprop_placeholder() method

In some cases you need to add a property but the contents of it
are not known at creation time, merely the extend of it.

This method allows you to create a property of a given size (filled
with garbage) while a pointer to the property data will be provided.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@…>
[dwg: Corrected commit message]
Signed-off-by: David Gibson <david@…>

Location:
cpukit
Files:
2 edited

Legend:

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

    r903d2ec ra1c3b41a  
    270270}
    271271
    272 int fdt_setprop(void *fdt, int nodeoffset, const char *name,
    273                 const void *val, int len)
     272int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
     273                            int len, void **prop_data)
    274274{
    275275        struct fdt_property *prop;
     
    284284                return err;
    285285
     286        *prop_data = prop->data;
     287        return 0;
     288}
     289
     290int fdt_setprop(void *fdt, int nodeoffset, const char *name,
     291                const void *val, int len)
     292{
     293        void *prop_data;
     294        int err;
     295
     296        err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
     297        if (err)
     298                return err;
     299
    286300        if (len)
    287                 memcpy(prop->data, val, len);
     301                memcpy(prop_data, val, len);
    288302        return 0;
    289303}
  • cpukit/include/libfdt.h

    r903d2ec ra1c3b41a  
    14501450
    14511451/**
     1452 * fdt_setprop _placeholder - allocate space for a property
     1453 * @fdt: pointer to the device tree blob
     1454 * @nodeoffset: offset of the node whose property to change
     1455 * @name: name of the property to change
     1456 * @len: length of the property value
     1457 * @prop_data: return pointer to property data
     1458 *
     1459 * fdt_setprop_placeholer() allocates the named property in the given node.
     1460 * If the property exists it is resized. In either case a pointer to the
     1461 * property data is returned.
     1462 *
     1463 * This function may insert or delete data from the blob, and will
     1464 * therefore change the offsets of some existing nodes.
     1465 *
     1466 * returns:
     1467 *      0, on success
     1468 *      -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
     1469 *              contain the new property value
     1470 *      -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
     1471 *      -FDT_ERR_BADLAYOUT,
     1472 *      -FDT_ERR_BADMAGIC,
     1473 *      -FDT_ERR_BADVERSION,
     1474 *      -FDT_ERR_BADSTATE,
     1475 *      -FDT_ERR_BADSTRUCTURE,
     1476 *      -FDT_ERR_BADLAYOUT,
     1477 *      -FDT_ERR_TRUNCATED, standard meanings
     1478 */
     1479int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
     1480                            int len, void **prop_data);
     1481
     1482/**
    14521483 * fdt_setprop_u32 - set a property to a 32-bit integer
    14531484 * @fdt: pointer to the device tree blob
Note: See TracChangeset for help on using the changeset viewer.