summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-05-19 19:32:08 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-05-19 19:32:08 +0000
commit784c27fb02cb6af25f49691ea3a98104260bee43 (patch)
tree5c0bbad0613d15724c0db8eb4ee344581c2832cd /sys
parentdab56c9bfcac04a28c9820fd977106d5d4d26f41 (diff)
Make fdt_node_add_property() behave like fdt_node_set_property() if the
property already exists.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/armv7/stand/efiboot/fdt.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/sys/arch/armv7/stand/efiboot/fdt.c b/sys/arch/armv7/stand/efiboot/fdt.c
index f49522965ea..8d95817a075 100644
--- a/sys/arch/armv7/stand/efiboot/fdt.c
+++ b/sys/arch/armv7/stand/efiboot/fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fdt.c,v 1.3 2016/05/17 23:16:10 kettenis Exp $ */
+/* $OpenBSD: fdt.c,v 1.4 2016/05/19 19:32:07 kettenis Exp $ */
/*
* Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net>
@@ -265,28 +265,30 @@ fdt_node_set_property(void *node, char *name, char *data, int len)
int
fdt_node_add_property(void *node, char *name, char *data, int len)
{
- uint32_t *ptr;
-
+ char *dummy;
+
if (!tree_inited)
return 0;
- ptr = (uint32_t *)node;
+ if (!fdt_node_property(node, name, &dummy)) {
+ uint32_t *ptr = (uint32_t *)node;
- if (betoh32(*ptr) != FDT_NODE_BEGIN)
- return 0;
+ if (betoh32(*ptr) != FDT_NODE_BEGIN)
+ return 0;
- ptr = skip_node_name(ptr + 1);
+ ptr = skip_node_name(ptr + 1);
- memmove(ptr + 3, ptr, tree.end - (char *)ptr);
- tree.struct_size += 3 * sizeof(uint32_t);
- if (tree.strings > tree.tree)
- tree.strings += 3 * sizeof(uint32_t);
- if (tree.memory > tree.tree)
- tree.memory += 3 * sizeof(uint32_t);
- tree.end += 3 * sizeof(uint32_t);
- *ptr++ = htobe32(FDT_PROPERTY);
- *ptr++ = htobe32(0);
- *ptr++ = htobe32(fdt_add_str(name));
+ memmove(ptr + 3, ptr, tree.end - (char *)ptr);
+ tree.struct_size += 3 * sizeof(uint32_t);
+ if (tree.strings > tree.tree)
+ tree.strings += 3 * sizeof(uint32_t);
+ if (tree.memory > tree.tree)
+ tree.memory += 3 * sizeof(uint32_t);
+ tree.end += 3 * sizeof(uint32_t);
+ *ptr++ = htobe32(FDT_PROPERTY);
+ *ptr++ = htobe32(0);
+ *ptr++ = htobe32(fdt_add_str(name));
+ }
return fdt_node_set_property(node, name, data, len);
}