Hi,
as the new translation function makes use of errnos as return value,
it probably makes sense to change the "get memory" function, too.
Also I think we should check that mem is not NULL in this function,
as it's exposed in the API. If node or mem is NULL, just return
EINVAL.
ok?
Patrick
diff --git sys/dev/ofw/fdt.c sys/dev/ofw/fdt.c
index 09ddcfc..8c0c0d2 100644
--- sys/dev/ofw/fdt.c
+++ sys/dev/ofw/fdt.c
@@ -498,26 +498,26 @@ fdt_get_memory_address(void *node, int idx, struct
fdt_memory *mem)
void *parent;
int ac, sc, off, ret, *in, inlen;
- if (node == NULL)
- return 1;
+ if (node == NULL || mem == NULL)
+ return EINVAL;
parent = fdt_parent_node(node);
if (parent == NULL)
- return 1;
+ return EINVAL;
/* We only support 32-bit (1), and 64-bit (2) wide addresses here. */
ret = fdt_node_property_int(parent, "#address-cells", &ac);
if (ret != 1 || ac <= 0 || ac > 2)
- return 1;
+ return EINVAL;
/* We only support 32-bit (1), and 64-bit (2) wide sizes here. */
ret = fdt_node_property_int(parent, "#size-cells", &sc);
if (ret != 1 || sc <= 0 || sc > 2)
- return 1;
+ return EINVAL;
inlen = fdt_node_property(node, "reg", (char **)&in) / sizeof(int);
if (inlen < ((idx + 1) * (ac + sc)))
- return 1;
+ return EINVAL;
off = idx * (ac + sc);