aboutsummaryrefslogtreecommitdiffstats
path: root/fdt_addresses.c
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-07-23 13:35:28 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-07-23 13:35:28 +0000
commitaa7bcf5ec65a3f4d0c68e4a08b736f1face35c60 (patch)
tree2eae59b2be4328d6017b7830dd29323c2ff2d0f4 /fdt_addresses.c
parent470576098ad9745f2e2864a6d65fcdd9742af23a (diff)
downloadsrc-aa7bcf5ec65a3f4d0c68e4a08b736f1face35c60.tar.gz
src-aa7bcf5ec65a3f4d0c68e4a08b736f1face35c60.zip
Import libfdt from dtc 1.4.7vendor/libfdt/1.4.7
Notes
Notes: svn path=/vendor-sys/libfdt/dist/; revision=336636 svn path=/vendor-sys/libfdt/1.4.7/; revision=336637; tag=vendor/libfdt/1.4.7
Diffstat (limited to 'fdt_addresses.c')
-rw-r--r--fdt_addresses.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/fdt_addresses.c b/fdt_addresses.c
index eff4dbcc729d..49537b578d03 100644
--- a/fdt_addresses.c
+++ b/fdt_addresses.c
@@ -1,6 +1,7 @@
/*
* libfdt - Flat Device Tree manipulation
* Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
+ * Copyright (C) 2018 embedded brains GmbH
*
* libfdt is dual licensed: you can use it either under the terms of
* the GPL, or the BSD license, at your option.
@@ -55,42 +56,32 @@
#include "libfdt_internal.h"
-int fdt_address_cells(const void *fdt, int nodeoffset)
+static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
{
- const fdt32_t *ac;
+ const fdt32_t *c;
int val;
int len;
- ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
- if (!ac)
+ c = fdt_getprop(fdt, nodeoffset, name, &len);
+ if (!c)
return 2;
- if (len != sizeof(*ac))
+ if (len != sizeof(*c))
return -FDT_ERR_BADNCELLS;
- val = fdt32_to_cpu(*ac);
+ val = fdt32_to_cpu(*c);
if ((val <= 0) || (val > FDT_MAX_NCELLS))
return -FDT_ERR_BADNCELLS;
return val;
}
-int fdt_size_cells(const void *fdt, int nodeoffset)
+int fdt_address_cells(const void *fdt, int nodeoffset)
{
- const fdt32_t *sc;
- int val;
- int len;
-
- sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
- if (!sc)
- return 2;
-
- if (len != sizeof(*sc))
- return -FDT_ERR_BADNCELLS;
-
- val = fdt32_to_cpu(*sc);
- if ((val < 0) || (val > FDT_MAX_NCELLS))
- return -FDT_ERR_BADNCELLS;
+ return fdt_cells(fdt, nodeoffset, "#address-cells");
+}
- return val;
+int fdt_size_cells(const void *fdt, int nodeoffset)
+{
+ return fdt_cells(fdt, nodeoffset, "#size-cells");
}