2 * libfdt - Flat Device Tree manipulation
3 * Copyright (C) 2006 David Gibson, IBM Corporation.
4 * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause
6 #include "libfdt_env.h"
15 #include "libfdt_internal.h"
17 struct fdt_errtabent {
21 #define FDT_ERRTABENT(val) \
22 [(val)] = { .str = #val, }
24 static struct fdt_errtabent fdt_errtable[] = {
25 FDT_ERRTABENT(FDT_ERR_NOTFOUND),
26 FDT_ERRTABENT(FDT_ERR_EXISTS),
27 FDT_ERRTABENT(FDT_ERR_NOSPACE),
29 FDT_ERRTABENT(FDT_ERR_BADOFFSET),
30 FDT_ERRTABENT(FDT_ERR_BADPATH),
31 FDT_ERRTABENT(FDT_ERR_BADSTATE),
33 FDT_ERRTABENT(FDT_ERR_TRUNCATED),
34 FDT_ERRTABENT(FDT_ERR_BADMAGIC),
35 FDT_ERRTABENT(FDT_ERR_BADVERSION),
36 FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
37 FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
39 #define FDT_ERRTABSIZE (sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
41 const char *fdt_strerror(int errval)
44 return "<valid offset/length>";
47 else if (errval > -FDT_ERRTABSIZE) {
48 const char *s = fdt_errtable[-errval].str;
54 return "<unknown error>";