mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-19 03:08:31 +00:00
6feed2a5ae
A number of style fixes across the files in this directory, including: * Correct invalid kernel-doc content. * Tidy up massive comment in fdt_region.c. * Use correct spelling of "U-Boot". * Replace tests of "! <var>" with "!<var>". * Replace "libfdt_env.h" with <libfdt_env.h>. Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Acked-by: Simon Glass <sjg@chromium.org>
55 lines
1,005 B
C
55 lines
1,005 B
C
/*
|
|
* libfdt - Flat Device Tree manipulation
|
|
* Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>
|
|
* SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
|
|
*/
|
|
#include <libfdt_env.h>
|
|
|
|
#ifndef USE_HOSTCC
|
|
#include <fdt.h>
|
|
#include <libfdt.h>
|
|
#else
|
|
#include "fdt_host.h"
|
|
#endif
|
|
|
|
#include "libfdt_internal.h"
|
|
|
|
int fdt_address_cells(const void *fdt, int nodeoffset)
|
|
{
|
|
const fdt32_t *ac;
|
|
int val;
|
|
int len;
|
|
|
|
ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
|
|
if (!ac)
|
|
return 2;
|
|
|
|
if (len != sizeof(*ac))
|
|
return -FDT_ERR_BADNCELLS;
|
|
|
|
val = fdt32_to_cpu(*ac);
|
|
if ((val <= 0) || (val > FDT_MAX_NCELLS))
|
|
return -FDT_ERR_BADNCELLS;
|
|
|
|
return val;
|
|
}
|
|
|
|
int fdt_size_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 val;
|
|
}
|