adt: Add adt_setprop()

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2022-03-09 20:35:48 +09:00
parent 123d1df1a7
commit 963b74765c
2 changed files with 15 additions and 0 deletions

View file

@ -129,6 +129,20 @@ const void *adt_getprop(const void *adt, int nodeoffset, const char *name, u32 *
return adt_getprop_namelen(adt, nodeoffset, name, strlen(name), lenp);
}
int adt_setprop(void *adt, int nodeoffset, const char *name, void *value, size_t len)
{
u32 plen;
void *prop = (void *)adt_getprop(adt, nodeoffset, name, &plen);
if (!prop)
return -ADT_ERR_NOTFOUND;
if (len != plen)
return -ADT_ERR_BADLENGTH;
memcpy(prop, value, len);
return len;
}
int adt_getprop_copy(const void *adt, int nodeoffset, const char *name, void *out, size_t len)
{
u32 plen;

View file

@ -82,6 +82,7 @@ const void *adt_getprop_by_offset(const void *adt, int offset, const char **name
const void *adt_getprop_namelen(const void *adt, int nodeoffset, const char *name, size_t namelen,
u32 *lenp);
const void *adt_getprop(const void *adt, int nodeoffset, const char *name, u32 *lenp);
int adt_setprop(void *adt, int nodeoffset, const char *name, void *value, size_t len);
int adt_getprop_copy(const void *adt, int nodeoffset, const char *name, void *out, size_t len);
#define ADT_GETPROP(adt, nodeoffset, name, val) \