mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-10 09:44:13 +00:00
adt: Add adt_setprop()
Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
123d1df1a7
commit
963b74765c
2 changed files with 15 additions and 0 deletions
14
src/adt.c
14
src/adt.c
|
@ -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;
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in a new issue