summaryrefslogtreecommitdiff
path: root/libfdt/fdt_sw.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2008-07-09 14:10:24 +1000
committerGerald Van Baren <vanbaren@cideas.com>2008-08-24 22:20:49 -0400
commitfc7758ee4f5782878f2e96876b7bc56cfee0ac66 (patch)
treed2b1bf6f4f5104265cfaccca64ac043955e2ff8a /libfdt/fdt_sw.c
parentc66830263af19831f2b7db307f79d1943febf7f9 (diff)
downloadu-boot-imx-fc7758ee4f5782878f2e96876b7bc56cfee0ac66.zip
u-boot-imx-fc7758ee4f5782878f2e96876b7bc56cfee0ac66.tar.gz
u-boot-imx-fc7758ee4f5782878f2e96876b7bc56cfee0ac66.tar.bz2
libfdt: Increase namespace-pollution paranoia
libfdt is supposed to easy to embed in projects all and sundry. Often, it won't be practical to separate the embedded libfdt's namespace from that of the surrounding project. Which means there can be namespace conflicts between even libfdt's internal/static functions and functions or macros coming from the surrounding project's headers via libfdt_env.h. This patch, therefore, renames a bunch of libfdt internal functions and macros and makes a few other chances to reduce the chances of namespace collisions with embedding projects. Specifically: - Internal functions (even static ones) are now named _fdt_*() - The type and (static) global for the error table in fdt_strerror() gain an fdt_ prefix - The unused macro PALIGN is removed - The memeq and streq macros are removed and open-coded in the users (they were only used once each) - Other macros gain an FDT_ prefix - To save some of the bulk from the previous change, an FDT_TAGALIGN() macro is introduced, where FDT_TAGALIGN(x) == FDT_ALIGN(x, FDT_TAGSIZE) Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt/fdt_sw.c')
-rw-r--r--libfdt/fdt_sw.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 92f8f0b..698329e 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -55,22 +55,22 @@
#include "libfdt_internal.h"
-static int sw_check_header(void *fdt)
+static int _fdt_sw_check_header(void *fdt)
{
- if (fdt_magic(fdt) != SW_MAGIC)
+ if (fdt_magic(fdt) != FDT_SW_MAGIC)
return -FDT_ERR_BADMAGIC;
/* FIXME: should check more details about the header state */
return 0;
}
-#define SW_CHECK_HEADER(fdt) \
+#define FDT_SW_CHECK_HEADER(fdt) \
{ \
int err; \
- if ((err = sw_check_header(fdt)) != 0) \
+ if ((err = _fdt_sw_check_header(fdt)) != 0) \
return err; \
}
-static void *grab_space(void *fdt, int len)
+static void *_fdt_grab_space(void *fdt, int len)
{
int offset = fdt_size_dt_struct(fdt);
int spaceleft;
@@ -94,13 +94,13 @@ int fdt_create(void *buf, int bufsize)
memset(buf, 0, bufsize);
- fdt_set_magic(fdt, SW_MAGIC);
+ fdt_set_magic(fdt, FDT_SW_MAGIC);
fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
fdt_set_totalsize(fdt, bufsize);
- fdt_set_off_mem_rsvmap(fdt, ALIGN(sizeof(struct fdt_header),
- sizeof(struct fdt_reserve_entry)));
+ fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
+ sizeof(struct fdt_reserve_entry)));
fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
fdt_set_off_dt_strings(fdt, bufsize);
@@ -112,7 +112,7 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
struct fdt_reserve_entry *re;
int offset;
- SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER(fdt);
if (fdt_size_dt_struct(fdt))
return -FDT_ERR_BADSTATE;
@@ -140,9 +140,9 @@ int fdt_begin_node(void *fdt, const char *name)
struct fdt_node_header *nh;
int namelen = strlen(name) + 1;
- SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER(fdt);
- nh = grab_space(fdt, sizeof(*nh) + ALIGN(namelen, FDT_TAGSIZE));
+ nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
if (! nh)
return -FDT_ERR_NOSPACE;
@@ -155,9 +155,9 @@ int fdt_end_node(void *fdt)
{
uint32_t *en;
- SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER(fdt);
- en = grab_space(fdt, FDT_TAGSIZE);
+ en = _fdt_grab_space(fdt, FDT_TAGSIZE);
if (! en)
return -FDT_ERR_NOSPACE;
@@ -165,7 +165,7 @@ int fdt_end_node(void *fdt)
return 0;
}
-static int find_add_string(void *fdt, const char *s)
+static int _fdt_find_add_string(void *fdt, const char *s)
{
char *strtab = (char *)fdt + fdt_totalsize(fdt);
const char *p;
@@ -193,13 +193,13 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
struct fdt_property *prop;
int nameoff;
- SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER(fdt);
- nameoff = find_add_string(fdt, name);
+ nameoff = _fdt_find_add_string(fdt, name);
if (nameoff == 0)
return -FDT_ERR_NOSPACE;
- prop = grab_space(fdt, sizeof(*prop) + ALIGN(len, FDT_TAGSIZE));
+ prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
if (! prop)
return -FDT_ERR_NOSPACE;
@@ -218,10 +218,10 @@ int fdt_finish(void *fdt)
uint32_t tag;
int offset, nextoffset;
- SW_CHECK_HEADER(fdt);
+ FDT_SW_CHECK_HEADER(fdt);
/* Add terminator */
- end = grab_space(fdt, sizeof(*end));
+ end = _fdt_grab_space(fdt, sizeof(*end));
if (! end)
return -FDT_ERR_NOSPACE;
*end = cpu_to_fdt32(FDT_END);