Changeset 6112fb0b in rtems for cpukit/dtc


Ignore:
Timestamp:
Jul 29, 2016, 9:55:48 AM (3 years ago)
Author:
Maxime Ripard <maxime.ripard@…>
Branches:
master
Children:
607b70f
Parents:
2086bbc8
git-author:
Maxime Ripard <maxime.ripard@…> (07/29/16 09:55:48)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/19/18 05:01:09)
Message:

libfdt: Add fdt_setprop_inplace_namelen_partial

Add a function to modify inplace only a portion of a property..

This is especially useful when the property is an array of values, and you
want to update one of them without changing the DT size.

Acked-by: Simon Glass <sjg@…>
Reviewed-by: David Gibson <david@…>
Signed-off-by: Maxime Ripard <maxime.ripard@…>
[dwg: Remove unnecessary unsigned qualifier, correct a comment]
Signed-off-by: David Gibson <david@…>

File:
1 edited

Legend:

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

    r2086bbc8 r6112fb0b  
    5656#include "libfdt_internal.h"
    5757
    58 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
    59                         const void *val, int len)
     58int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
     59                                        const char *name, int namelen,
     60                                        uint32_t idx, const void *val,
     61                                        int len)
    6062{
    6163        void *propval;
    6264        int proplen;
    6365
    64         propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen);
     66        propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,
     67                                        &proplen);
     68        if (!propval)
     69                return proplen;
     70
     71        if (proplen < (len + idx))
     72                return -FDT_ERR_NOSPACE;
     73
     74        memcpy((char *)propval + idx, val, len);
     75        return 0;
     76}
     77
     78int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
     79                        const void *val, int len)
     80{
     81        const void *propval;
     82        int proplen;
     83
     84        propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
    6585        if (! propval)
    6686                return proplen;
     
    6989                return -FDT_ERR_NOSPACE;
    7090
    71         memcpy(propval, val, len);
    72         return 0;
     91        return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,
     92                                                   strlen(name), 0,
     93                                                   val, len);
    7394}
    7495
Note: See TracChangeset for help on using the changeset viewer.