libfdt: Rename and publish _fdt_check_header()
It's potentially useful for users of libfdt to sanity check a device tree (or, rather, a blob of data which may or may not be a device tree) before processing it in more detail with libfdt. This patch renames the libfdt internal function _fdt_check_header() to fdt_check_header() and makes it a published function, so it can now be used for this purpose. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>main
parent
2d50f8f9dd
commit
96b5fad3a1
|
@ -55,7 +55,7 @@
|
|||
|
||||
#include "libfdt_internal.h"
|
||||
|
||||
int _fdt_check_header(const void *fdt)
|
||||
int fdt_check_header(const void *fdt)
|
||||
{
|
||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||
/* Complete tree */
|
||||
|
@ -143,7 +143,7 @@ const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
|
|||
|
||||
int fdt_move(const void *fdt, void *buf, int bufsize)
|
||||
{
|
||||
int err = _fdt_check_header(fdt);
|
||||
int err = fdt_check_header(fdt);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#define CHECK_HEADER(fdt) \
|
||||
{ \
|
||||
int err; \
|
||||
if ((err = _fdt_check_header(fdt)) != 0) \
|
||||
if ((err = fdt_check_header(fdt)) != 0) \
|
||||
return err; \
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
|
|||
const struct fdt_node_header *nh;
|
||||
int err;
|
||||
|
||||
if ((err = _fdt_check_header(fdt)) != 0)
|
||||
if ((err = fdt_check_header(fdt)) != 0)
|
||||
goto fail;
|
||||
|
||||
err = -FDT_ERR_BADOFFSET;
|
||||
|
@ -222,7 +222,7 @@ const struct fdt_property *fdt_get_property(const void *fdt,
|
|||
int offset, nextoffset;
|
||||
int err;
|
||||
|
||||
if ((err = _fdt_check_header(fdt)) != 0)
|
||||
if ((err = fdt_check_header(fdt)) != 0)
|
||||
goto fail;
|
||||
|
||||
err = -FDT_ERR_BADOFFSET;
|
||||
|
|
|
@ -59,7 +59,7 @@ static int rw_check_header(void *fdt)
|
|||
{
|
||||
int err;
|
||||
|
||||
if ((err = _fdt_check_header(fdt)))
|
||||
if ((err = fdt_check_header(fdt)))
|
||||
return err;
|
||||
if (fdt_version(fdt) < 0x11)
|
||||
return -FDT_ERR_BADVERSION;
|
||||
|
|
|
@ -79,6 +79,22 @@
|
|||
|
||||
#define FDT_ERR_MAX 12
|
||||
|
||||
/* Low-level functions (you probably don't need these) */
|
||||
|
||||
const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
|
||||
static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
|
||||
{
|
||||
return (void *)fdt_offset_ptr(fdt, offset, checklen);
|
||||
}
|
||||
|
||||
|
||||
#define fdt_offset_ptr_typed(fdt, offset, var) \
|
||||
((typeof(var))(fdt_offset_ptr((fdt), (offset), sizeof(*(var)))))
|
||||
#define fdt_offset_ptr_typed_w(fdt, offset, var) \
|
||||
((typeof(var))(fdt_offset_ptr_w((fdt), (offset), sizeof(*(var)))))
|
||||
|
||||
/* General functions */
|
||||
|
||||
#define fdt_get_header(fdt, field) \
|
||||
(fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
|
||||
#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
|
||||
|
@ -95,18 +111,7 @@
|
|||
#define fdt_set_header(fdt, field, val) \
|
||||
((struct fdt_header *)(fdt))->field = cpu_to_fdt32(val)
|
||||
|
||||
const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
|
||||
static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
|
||||
{
|
||||
return (void *)fdt_offset_ptr(fdt, offset, checklen);
|
||||
}
|
||||
|
||||
|
||||
#define fdt_offset_ptr_typed(fdt, offset, var) \
|
||||
((typeof(var))(fdt_offset_ptr((fdt), (offset), sizeof(*(var)))))
|
||||
#define fdt_offset_ptr_typed_w(fdt, offset, var) \
|
||||
((typeof(var))(fdt_offset_ptr_w((fdt), (offset), sizeof(*(var)))))
|
||||
|
||||
int fdt_check_header(const void *fdt);
|
||||
int fdt_move(const void *fdt, void *buf, int bufsize);
|
||||
|
||||
/* Read-only functions */
|
||||
|
|
|
@ -58,7 +58,6 @@
|
|||
#define memeq(p, q, n) (memcmp((p), (q), (n)) == 0)
|
||||
#define streq(p, q) (strcmp((p), (q)) == 0)
|
||||
|
||||
int _fdt_check_header(const void *fdt);
|
||||
uint32_t _fdt_next_tag(const void *fdt, int startoffset, int *nextoffset);
|
||||
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
|
||||
int _fdt_node_end_offset(void *fdt, int nodeoffset);
|
||||
|
|
Loading…
Reference in New Issue