]>
git.ipfire.org Git - people/ms/u-boot.git/blob - lib/libfdt/fdt_addresses.c
2 * libfdt - Flat Device Tree manipulation
3 * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
4 * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
6 #include "libfdt_env.h"
15 #include "libfdt_internal.h"
17 int fdt_address_cells(const void *fdt
, int nodeoffset
)
23 ac
= fdt_getprop(fdt
, nodeoffset
, "#address-cells", &len
);
27 if (len
!= sizeof(*ac
))
28 return -FDT_ERR_BADNCELLS
;
30 val
= fdt32_to_cpu(*ac
);
31 if ((val
<= 0) || (val
> FDT_MAX_NCELLS
))
32 return -FDT_ERR_BADNCELLS
;
37 int fdt_size_cells(const void *fdt
, int nodeoffset
)
43 sc
= fdt_getprop(fdt
, nodeoffset
, "#size-cells", &len
);
47 if (len
!= sizeof(*sc
))
48 return -FDT_ERR_BADNCELLS
;
50 val
= fdt32_to_cpu(*sc
);
51 if ((val
< 0) || (val
> FDT_MAX_NCELLS
))
52 return -FDT_ERR_BADNCELLS
;