2 * libfdt - Flat Device Tree manipulation
3 * Copyright (C) 2006 David Gibson, IBM Corporation.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libfdt_env.h"
27 #include "libfdt_internal.h"
33 #define ERRTABENT(val) \
34 [(val)] = { .str = #val, }
36 static struct errtabent errtable[] = {
37 ERRTABENT(FDT_ERR_NOTFOUND),
38 ERRTABENT(FDT_ERR_EXISTS),
39 ERRTABENT(FDT_ERR_NOSPACE),
41 ERRTABENT(FDT_ERR_BADOFFSET),
42 ERRTABENT(FDT_ERR_BADPATH),
43 ERRTABENT(FDT_ERR_BADSTATE),
45 ERRTABENT(FDT_ERR_TRUNCATED),
46 ERRTABENT(FDT_ERR_BADMAGIC),
47 ERRTABENT(FDT_ERR_BADVERSION),
48 ERRTABENT(FDT_ERR_BADSTRUCTURE),
49 ERRTABENT(FDT_ERR_BADLAYOUT),
51 #define ERRTABSIZE (sizeof(errtable) / sizeof(errtable[0]))
53 const char *fdt_strerror(int errval)
56 return "<valid offset/length>";
59 else if (errval > -ERRTABSIZE) {
60 const char *s = errtable[-errval].str;
66 return "<unknown error>";
69 #endif /* CONFIG_OF_LIBFDT */