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>
@ -102,7 +102,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
@@ -102,7 +102,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
{
int depth;
CHECK_HEADER(fdt);
FDT_CHECK_HEADER(fdt);
for (depth = 0;
offset >= 0;
@ -110,7 +110,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
@@ -110,7 +110,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
if (strcmp(fdt_string(fdt, namestroff), name) == 0) {
/* Found it! */
int len = fdt32_to_cpu(prop->len);
prop = fdt_offset_ptr(fdt, offset,
@ -268,7 +268,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
@@ -268,7 +268,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
int offset, depth, namelen;
const char *name;
CHECK_HEADER(fdt);
FDT_CHECK_HEADER(fdt);
if (buflen < 2)
return -FDT_ERR_NOSPACE;
@ -321,7 +321,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
@@ -321,7 +321,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
int offset, depth;
int supernodeoffset = -FDT_ERR_INTERNAL;
CHECK_HEADER(fdt);
FDT_CHECK_HEADER(fdt);
if (supernodedepth < 0)
return -FDT_ERR_NOTFOUND;
@ -380,7 +380,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
@@ -380,7 +380,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
const void *val;
int len;
CHECK_HEADER(fdt);
FDT_CHECK_HEADER(fdt);
/* FIXME: The algorithm here is pretty horrible: we scan each
* property of a node in fdt_getprop(), then if that didn't
@ -445,7 +445,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
@@ -445,7 +445,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
{
int offset, err;
CHECK_HEADER(fdt);
FDT_CHECK_HEADER(fdt);
/* FIXME: The algorithm here is pretty horrible: we scan each
* property of a node in fdt_node_check_compatible(), then if
static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
{
char *p = splicepoint;
char *end = (char *)fdt + _blob_data_size(fdt);
char *end = (char *)fdt + _fdt_data_size(fdt);
if (((p + oldlen) < p) || ((p + oldlen) > end))
return -FDT_ERR_BADOFFSET;
@ -107,12 +107,12 @@ static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
@@ -107,12 +107,12 @@ static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
return 0;
}
static int _blob_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
static int _resize_property(void *fdt, int nodeoffset, const char *name, int len,
struct fdt_property **prop)
static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
int len, struct fdt_property **prop)
{
int oldlen;
int err;
@ -212,17 +212,16 @@ static int _resize_property(void *fdt, int nodeoffset, const char *name, int len
@@ -212,17 +212,16 @@ static int _resize_property(void *fdt, int nodeoffset, const char *name, int len
if (! (*prop))
return oldlen;
if ((err = _blob_splice_struct(fdt, (*prop)->data,
ALIGN(oldlen, FDT_TAGSIZE),
ALIGN(len, FDT_TAGSIZE))))
if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
FDT_TAGALIGN(len))))
return err;
(*prop)->len = cpu_to_fdt32(len);
return 0;
}
static int _add_property(void *fdt, int nodeoffset, const char *name, int len,
struct fdt_property **prop)
static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
int len, struct fdt_property **prop)
{
int proplen;
int nextoffset;
@ -232,14 +231,14 @@ static int _add_property(void *fdt, int nodeoffset, const char *name, int len,
@@ -232,14 +231,14 @@ static int _add_property(void *fdt, int nodeoffset, const char *name, int len,
if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@ -315,7 +314,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@@ -315,7 +314,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@ -331,14 +330,14 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@@ -331,14 +330,14 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,