2007-11-01 06:49:26 +01:00
|
|
|
/*
|
|
|
|
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dtc.h"
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
#ifdef TRACE_CHECKS
|
|
|
|
#define TRACE(c, ...) \
|
|
|
|
do { \
|
|
|
|
fprintf(stderr, "=== %s: ", (c)->name); \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
fprintf(stderr, "\n"); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define TRACE(c, fmt, ...) do { } while (0)
|
|
|
|
#endif
|
2007-11-01 06:49:26 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
enum checkstatus {
|
|
|
|
UNCHECKED = 0,
|
|
|
|
PREREQ,
|
|
|
|
PASSED,
|
|
|
|
FAILED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct check;
|
|
|
|
|
|
|
|
typedef void (*tree_check_fn)(struct check *c, struct node *dt);
|
|
|
|
typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
|
|
|
|
typedef void (*prop_check_fn)(struct check *c, struct node *dt,
|
|
|
|
struct node *node, struct property *prop);
|
|
|
|
|
|
|
|
struct check {
|
|
|
|
const char *name;
|
|
|
|
tree_check_fn tree_fn;
|
|
|
|
node_check_fn node_fn;
|
|
|
|
prop_check_fn prop_fn;
|
|
|
|
void *data;
|
2012-07-08 15:25:21 +02:00
|
|
|
bool warn, error;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
enum checkstatus status;
|
2013-10-28 11:06:53 +01:00
|
|
|
bool inprogress;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
int num_prereqs;
|
|
|
|
struct check **prereq;
|
|
|
|
};
|
|
|
|
|
2012-07-08 15:25:22 +02:00
|
|
|
#define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \
|
|
|
|
static struct check nm = { \
|
|
|
|
.name = #nm, \
|
|
|
|
.tree_fn = (tfn), \
|
|
|
|
.node_fn = (nfn), \
|
|
|
|
.prop_fn = (pfn), \
|
|
|
|
.data = (d), \
|
2012-07-08 15:25:21 +02:00
|
|
|
.warn = (w), \
|
|
|
|
.error = (e), \
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
.status = UNCHECKED, \
|
|
|
|
.num_prereqs = ARRAY_SIZE(nm##_prereqs), \
|
|
|
|
.prereq = nm##_prereqs, \
|
|
|
|
};
|
2012-07-08 15:25:21 +02:00
|
|
|
#define WARNING(nm, tfn, nfn, pfn, d, ...) \
|
2012-07-08 15:25:22 +02:00
|
|
|
CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__)
|
2012-07-08 15:25:21 +02:00
|
|
|
#define ERROR(nm, tfn, nfn, pfn, d, ...) \
|
2012-07-08 15:25:22 +02:00
|
|
|
CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, true, __VA_ARGS__)
|
|
|
|
#define CHECK(nm, tfn, nfn, pfn, d, ...) \
|
|
|
|
CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, false, __VA_ARGS__)
|
2012-07-08 15:25:21 +02:00
|
|
|
|
|
|
|
#define TREE_WARNING(nm, d, ...) \
|
|
|
|
WARNING(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
|
|
|
|
#define TREE_ERROR(nm, d, ...) \
|
|
|
|
ERROR(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
|
2012-07-08 15:25:22 +02:00
|
|
|
#define TREE_CHECK(nm, d, ...) \
|
|
|
|
CHECK(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
|
2012-07-08 15:25:21 +02:00
|
|
|
#define NODE_WARNING(nm, d, ...) \
|
|
|
|
WARNING(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
|
|
|
|
#define NODE_ERROR(nm, d, ...) \
|
|
|
|
ERROR(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
|
2012-07-08 15:25:22 +02:00
|
|
|
#define NODE_CHECK(nm, d, ...) \
|
|
|
|
CHECK(nm, NULL, check_##nm, NULL, d, __VA_ARGS__)
|
2012-07-08 15:25:21 +02:00
|
|
|
#define PROP_WARNING(nm, d, ...) \
|
|
|
|
WARNING(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
|
|
|
|
#define PROP_ERROR(nm, d, ...) \
|
|
|
|
ERROR(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
|
2012-07-08 15:25:22 +02:00
|
|
|
#define PROP_CHECK(nm, d, ...) \
|
|
|
|
CHECK(nm, NULL, NULL, check_##nm, d, __VA_ARGS__)
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
|
2007-12-07 08:08:03 +01:00
|
|
|
#ifdef __GNUC__
|
|
|
|
static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
|
|
|
|
#endif
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
static inline void check_msg(struct check *c, const char *fmt, ...)
|
2007-11-01 06:49:26 +01:00
|
|
|
{
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
2012-07-08 15:25:21 +02:00
|
|
|
if ((c->warn && (quiet < 1))
|
|
|
|
|| (c->error && (quiet < 2))) {
|
|
|
|
fprintf(stderr, "%s (%s): ",
|
|
|
|
(c->error) ? "ERROR" : "Warning", c->name);
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
}
|
|
|
|
|
2007-12-04 23:34:53 +01:00
|
|
|
#define FAIL(c, ...) \
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
do { \
|
|
|
|
TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
|
|
|
|
(c)->status = FAILED; \
|
2007-12-04 23:34:53 +01:00
|
|
|
check_msg((c), __VA_ARGS__); \
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static void check_nodes_props(struct check *c, struct node *dt, struct node *node)
|
|
|
|
{
|
|
|
|
struct node *child;
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
TRACE(c, "%s", node->fullpath);
|
|
|
|
if (c->node_fn)
|
|
|
|
c->node_fn(c, dt, node);
|
|
|
|
|
|
|
|
if (c->prop_fn)
|
|
|
|
for_each_property(node, prop) {
|
|
|
|
TRACE(c, "%s\t'%s'", node->fullpath, prop->name);
|
|
|
|
c->prop_fn(c, dt, node, prop);
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
for_each_child(node, child)
|
|
|
|
check_nodes_props(c, dt, child);
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:06:53 +01:00
|
|
|
static bool run_check(struct check *c, struct node *dt)
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
{
|
2013-10-28 11:06:53 +01:00
|
|
|
bool error = false;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
assert(!c->inprogress);
|
|
|
|
|
|
|
|
if (c->status != UNCHECKED)
|
|
|
|
goto out;
|
|
|
|
|
2013-10-28 11:06:53 +01:00
|
|
|
c->inprogress = true;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
|
|
|
|
for (i = 0; i < c->num_prereqs; i++) {
|
|
|
|
struct check *prq = c->prereq[i];
|
2013-10-28 11:06:53 +01:00
|
|
|
error = error || run_check(prq, dt);
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
if (prq->status != PASSED) {
|
|
|
|
c->status = PREREQ;
|
|
|
|
check_msg(c, "Failed prerequisite '%s'",
|
|
|
|
c->prereq[i]->name);
|
|
|
|
}
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
if (c->status != UNCHECKED)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (c->node_fn || c->prop_fn)
|
|
|
|
check_nodes_props(c, dt, dt);
|
|
|
|
|
|
|
|
if (c->tree_fn)
|
|
|
|
c->tree_fn(c, dt);
|
|
|
|
if (c->status == UNCHECKED)
|
|
|
|
c->status = PASSED;
|
2007-11-01 06:49:26 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
TRACE(c, "\tCompleted, status %d", c->status);
|
|
|
|
|
|
|
|
out:
|
2013-10-28 11:06:53 +01:00
|
|
|
c->inprogress = false;
|
2012-07-08 15:25:21 +02:00
|
|
|
if ((c->status != PASSED) && (c->error))
|
2013-10-28 11:06:53 +01:00
|
|
|
error = true;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-12-04 23:40:23 +01:00
|
|
|
/*
|
|
|
|
* Utility check functions
|
|
|
|
*/
|
|
|
|
|
2012-07-08 15:25:22 +02:00
|
|
|
/* A check which always fails, for testing purposes only */
|
|
|
|
static inline void check_always_fail(struct check *c, struct node *dt)
|
|
|
|
{
|
|
|
|
FAIL(c, "always_fail check");
|
|
|
|
}
|
|
|
|
TREE_CHECK(always_fail, NULL);
|
|
|
|
|
2007-12-04 23:40:23 +01:00
|
|
|
static void check_is_string(struct check *c, struct node *root,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
char *propname = c->data;
|
|
|
|
|
|
|
|
prop = get_property(node, propname);
|
|
|
|
if (!prop)
|
|
|
|
return; /* Not present, assumed ok */
|
|
|
|
|
|
|
|
if (!data_is_one_string(prop->val))
|
|
|
|
FAIL(c, "\"%s\" property in %s is not a string",
|
|
|
|
propname, node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
#define WARNING_IF_NOT_STRING(nm, propname) \
|
|
|
|
WARNING(nm, NULL, check_is_string, NULL, (propname))
|
|
|
|
#define ERROR_IF_NOT_STRING(nm, propname) \
|
|
|
|
ERROR(nm, NULL, check_is_string, NULL, (propname))
|
2007-12-04 23:40:23 +01:00
|
|
|
|
2007-12-06 06:59:45 +01:00
|
|
|
static void check_is_cell(struct check *c, struct node *root,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
char *propname = c->data;
|
|
|
|
|
|
|
|
prop = get_property(node, propname);
|
|
|
|
if (!prop)
|
|
|
|
return; /* Not present, assumed ok */
|
|
|
|
|
|
|
|
if (prop->val.len != sizeof(cell_t))
|
|
|
|
FAIL(c, "\"%s\" property in %s is not a single cell",
|
|
|
|
propname, node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
#define WARNING_IF_NOT_CELL(nm, propname) \
|
|
|
|
WARNING(nm, NULL, check_is_cell, NULL, (propname))
|
|
|
|
#define ERROR_IF_NOT_CELL(nm, propname) \
|
|
|
|
ERROR(nm, NULL, check_is_cell, NULL, (propname))
|
2007-12-06 06:59:45 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
/*
|
|
|
|
* Structural check functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void check_duplicate_node_names(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct node *child, *child2;
|
|
|
|
|
|
|
|
for_each_child(node, child)
|
2007-11-01 06:49:26 +01:00
|
|
|
for (child2 = child->next_sibling;
|
|
|
|
child2;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
child2 = child2->next_sibling)
|
2007-11-01 06:49:26 +01:00
|
|
|
if (streq(child->name, child2->name))
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
FAIL(c, "Duplicate node name %s",
|
|
|
|
child->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_ERROR(duplicate_node_names, NULL);
|
2007-11-01 06:49:26 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
static void check_duplicate_property_names(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop, *prop2;
|
|
|
|
|
2012-08-08 06:50:15 +02:00
|
|
|
for_each_property(node, prop) {
|
|
|
|
for (prop2 = prop->next; prop2; prop2 = prop2->next) {
|
|
|
|
if (prop2->deleted)
|
|
|
|
continue;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
if (streq(prop->name, prop2->name))
|
|
|
|
FAIL(c, "Duplicate property name %s in %s",
|
|
|
|
prop->name, node->fullpath);
|
2012-08-08 06:50:15 +02:00
|
|
|
}
|
|
|
|
}
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_ERROR(duplicate_property_names, NULL);
|
2007-11-01 06:49:26 +01:00
|
|
|
|
2008-02-27 03:45:13 +01:00
|
|
|
#define LOWERCASE "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
#define DIGITS "0123456789"
|
|
|
|
#define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-"
|
|
|
|
|
|
|
|
static void check_node_name_chars(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
int n = strspn(node->name, c->data);
|
|
|
|
|
|
|
|
if (n < strlen(node->name))
|
|
|
|
FAIL(c, "Bad character '%c' in node %s",
|
|
|
|
node->name[n], node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_ERROR(node_name_chars, PROPNODECHARS "@");
|
2008-02-27 03:45:13 +01:00
|
|
|
|
|
|
|
static void check_node_name_format(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
if (strchr(get_unitname(node), '@'))
|
|
|
|
FAIL(c, "Node %s has multiple '@' characters in name",
|
|
|
|
node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_ERROR(node_name_format, NULL, &node_name_chars);
|
2008-02-27 03:45:13 +01:00
|
|
|
|
|
|
|
static void check_property_name_chars(struct check *c, struct node *dt,
|
|
|
|
struct node *node, struct property *prop)
|
|
|
|
{
|
|
|
|
int n = strspn(prop->name, c->data);
|
|
|
|
|
|
|
|
if (n < strlen(prop->name))
|
|
|
|
FAIL(c, "Bad character '%c' in property name \"%s\", node %s",
|
|
|
|
prop->name[n], prop->name, node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
PROP_ERROR(property_name_chars, PROPNODECHARS);
|
2008-02-27 03:45:13 +01:00
|
|
|
|
2010-02-23 09:56:41 +01:00
|
|
|
#define DESCLABEL_FMT "%s%s%s%s%s"
|
|
|
|
#define DESCLABEL_ARGS(node,prop,mark) \
|
|
|
|
((mark) ? "value of " : ""), \
|
|
|
|
((prop) ? "'" : ""), \
|
|
|
|
((prop) ? (prop)->name : ""), \
|
|
|
|
((prop) ? "' in " : ""), (node)->fullpath
|
|
|
|
|
|
|
|
static void check_duplicate_label(struct check *c, struct node *dt,
|
|
|
|
const char *label, struct node *node,
|
|
|
|
struct property *prop, struct marker *mark)
|
|
|
|
{
|
|
|
|
struct node *othernode = NULL;
|
|
|
|
struct property *otherprop = NULL;
|
|
|
|
struct marker *othermark = NULL;
|
|
|
|
|
|
|
|
othernode = get_node_by_label(dt, label);
|
|
|
|
|
|
|
|
if (!othernode)
|
|
|
|
otherprop = get_property_by_label(dt, label, &othernode);
|
|
|
|
if (!othernode)
|
|
|
|
othermark = get_marker_label(dt, label, &othernode,
|
|
|
|
&otherprop);
|
|
|
|
|
|
|
|
if (!othernode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((othernode != node) || (otherprop != prop) || (othermark != mark))
|
|
|
|
FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT
|
|
|
|
" and " DESCLABEL_FMT,
|
|
|
|
label, DESCLABEL_ARGS(node, prop, mark),
|
|
|
|
DESCLABEL_ARGS(othernode, otherprop, othermark));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_duplicate_label_node(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
2010-02-24 08:22:17 +01:00
|
|
|
struct label *l;
|
|
|
|
|
|
|
|
for_each_label(node->labels, l)
|
|
|
|
check_duplicate_label(c, dt, l->label, node, NULL, NULL);
|
2010-02-23 09:56:41 +01:00
|
|
|
}
|
|
|
|
static void check_duplicate_label_prop(struct check *c, struct node *dt,
|
|
|
|
struct node *node, struct property *prop)
|
|
|
|
{
|
|
|
|
struct marker *m = prop->val.markers;
|
2010-02-24 08:22:17 +01:00
|
|
|
struct label *l;
|
2010-02-23 09:56:41 +01:00
|
|
|
|
2010-02-24 08:22:17 +01:00
|
|
|
for_each_label(prop->labels, l)
|
|
|
|
check_duplicate_label(c, dt, l->label, node, prop, NULL);
|
2010-02-23 09:56:41 +01:00
|
|
|
|
|
|
|
for_each_marker_of_type(m, LABEL)
|
|
|
|
check_duplicate_label(c, dt, m->ref, node, prop, m);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
ERROR(duplicate_label, NULL, check_duplicate_label_node,
|
|
|
|
check_duplicate_label_prop, NULL);
|
2010-02-23 09:56:41 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
static void check_explicit_phandles(struct check *c, struct node *root,
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
struct node *node, struct property *prop)
|
2007-11-01 06:49:26 +01:00
|
|
|
{
|
dtc: Handle linux,phandle properties which self-reference
Currently, dtc will generate phandles for nodes which are referenced
elsewhere in the tree. phandles can also be explicitly assigned by
defining the linux,phandle property. However, there is no way,
currently to tell dtc to generate a phandle for a node if it is not
referenced elsewhere. This is inconvenient when it's expected that
later processing on the flat tree might add nodes which _will_
the node in question.
One way one might attempt to do this is with the construct:
mynode: mynode {
linux,phandle = <&mynode>;
/* ... */
};
Though it's a trifle odd, there's really only one sensible meaning
which can be assigned to this construct: allocate a unique phandle to
"mynode" and put that in its linux,phandle property (as always).
Currently, however, dtc will choke on this self-reference. This patch
corrects this, making the construct above give the expected results.
It also ensures a more meaningful error message is given if you
attempt to process the nonsensical construct:
mynode: mynode {
linux,phandle = <&someothernode>;
/* ... */
};
The 'references' testcase is extended to cover this case, as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-07 02:49:44 +01:00
|
|
|
struct marker *m;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
struct node *other;
|
2007-11-01 06:49:26 +01:00
|
|
|
cell_t phandle;
|
|
|
|
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
if (!streq(prop->name, "phandle")
|
|
|
|
&& !streq(prop->name, "linux,phandle"))
|
|
|
|
return;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
|
|
|
|
if (prop->val.len != sizeof(cell_t)) {
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
FAIL(c, "%s has bad length (%d) %s property",
|
|
|
|
node->fullpath, prop->val.len, prop->name);
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
return;
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|
|
|
|
|
dtc: Handle linux,phandle properties which self-reference
Currently, dtc will generate phandles for nodes which are referenced
elsewhere in the tree. phandles can also be explicitly assigned by
defining the linux,phandle property. However, there is no way,
currently to tell dtc to generate a phandle for a node if it is not
referenced elsewhere. This is inconvenient when it's expected that
later processing on the flat tree might add nodes which _will_
the node in question.
One way one might attempt to do this is with the construct:
mynode: mynode {
linux,phandle = <&mynode>;
/* ... */
};
Though it's a trifle odd, there's really only one sensible meaning
which can be assigned to this construct: allocate a unique phandle to
"mynode" and put that in its linux,phandle property (as always).
Currently, however, dtc will choke on this self-reference. This patch
corrects this, making the construct above give the expected results.
It also ensures a more meaningful error message is given if you
attempt to process the nonsensical construct:
mynode: mynode {
linux,phandle = <&someothernode>;
/* ... */
};
The 'references' testcase is extended to cover this case, as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-07 02:49:44 +01:00
|
|
|
m = prop->val.markers;
|
|
|
|
for_each_marker_of_type(m, REF_PHANDLE) {
|
|
|
|
assert(m->offset == 0);
|
|
|
|
if (node != get_node_by_ref(root, m->ref))
|
|
|
|
/* "Set this node's phandle equal to some
|
|
|
|
* other node's phandle". That's nonsensical
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
* by construction. */ {
|
|
|
|
FAIL(c, "%s in %s is a reference to another node",
|
|
|
|
prop->name, node->fullpath);
|
|
|
|
return;
|
|
|
|
}
|
dtc: Handle linux,phandle properties which self-reference
Currently, dtc will generate phandles for nodes which are referenced
elsewhere in the tree. phandles can also be explicitly assigned by
defining the linux,phandle property. However, there is no way,
currently to tell dtc to generate a phandle for a node if it is not
referenced elsewhere. This is inconvenient when it's expected that
later processing on the flat tree might add nodes which _will_
the node in question.
One way one might attempt to do this is with the construct:
mynode: mynode {
linux,phandle = <&mynode>;
/* ... */
};
Though it's a trifle odd, there's really only one sensible meaning
which can be assigned to this construct: allocate a unique phandle to
"mynode" and put that in its linux,phandle property (as always).
Currently, however, dtc will choke on this self-reference. This patch
corrects this, making the construct above give the expected results.
It also ensures a more meaningful error message is given if you
attempt to process the nonsensical construct:
mynode: mynode {
linux,phandle = <&someothernode>;
/* ... */
};
The 'references' testcase is extended to cover this case, as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2008-11-07 02:49:44 +01:00
|
|
|
/* But setting this node's phandle equal to its own
|
|
|
|
* phandle is allowed - that means allocate a unique
|
|
|
|
* phandle for this node, even if it's not otherwise
|
|
|
|
* referenced. The value will be filled in later, so
|
|
|
|
* no further checking for now. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
phandle = propval_cell(prop);
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
if ((phandle == 0) || (phandle == -1)) {
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
FAIL(c, "%s has bad value (0x%x) in %s property",
|
|
|
|
node->fullpath, phandle, prop->name);
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
if (node->phandle && (node->phandle != phandle))
|
|
|
|
FAIL(c, "%s has %s property which replaces existing phandle information",
|
|
|
|
node->fullpath, prop->name);
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
other = get_node_by_phandle(root, phandle);
|
Support ePAPR compliant phandle properties
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2009-11-26 05:37:13 +01:00
|
|
|
if (other && (other != node)) {
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
|
|
|
|
node->fullpath, phandle, other->fullpath);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
node->phandle = phandle;
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
PROP_ERROR(explicit_phandles, NULL);
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
|
2007-12-04 23:40:23 +01:00
|
|
|
static void check_name_properties(struct check *c, struct node *root,
|
|
|
|
struct node *node)
|
|
|
|
{
|
2008-02-28 10:53:00 +01:00
|
|
|
struct property **pp, *prop = NULL;
|
|
|
|
|
|
|
|
for (pp = &node->proplist; *pp; pp = &((*pp)->next))
|
|
|
|
if (streq((*pp)->name, "name")) {
|
|
|
|
prop = *pp;
|
|
|
|
break;
|
|
|
|
}
|
2007-12-04 23:40:23 +01:00
|
|
|
|
|
|
|
if (!prop)
|
|
|
|
return; /* No name property, that's fine */
|
|
|
|
|
|
|
|
if ((prop->val.len != node->basenamelen+1)
|
2008-07-07 03:19:13 +02:00
|
|
|
|| (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) {
|
2007-12-04 23:40:23 +01:00
|
|
|
FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead"
|
|
|
|
" of base node name)", node->fullpath, prop->val.val);
|
2008-07-07 03:19:13 +02:00
|
|
|
} else {
|
|
|
|
/* The name property is correct, and therefore redundant.
|
|
|
|
* Delete it */
|
|
|
|
*pp = prop->next;
|
|
|
|
free(prop->name);
|
|
|
|
data_free(prop->val);
|
|
|
|
free(prop);
|
|
|
|
}
|
2007-12-04 23:40:23 +01:00
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
ERROR_IF_NOT_STRING(name_is_string, "name");
|
|
|
|
NODE_ERROR(name_properties, NULL, &name_is_string);
|
2007-12-04 23:40:23 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
/*
|
|
|
|
* Reference fixup functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void fixup_phandle_references(struct check *c, struct node *dt,
|
|
|
|
struct node *node, struct property *prop)
|
|
|
|
{
|
2008-02-28 06:42:15 +01:00
|
|
|
struct marker *m = prop->val.markers;
|
|
|
|
struct node *refnode;
|
|
|
|
cell_t phandle;
|
|
|
|
|
|
|
|
for_each_marker_of_type(m, REF_PHANDLE) {
|
|
|
|
assert(m->offset + sizeof(cell_t) <= prop->val.len);
|
|
|
|
|
|
|
|
refnode = get_node_by_ref(dt, m->ref);
|
|
|
|
if (! refnode) {
|
|
|
|
FAIL(c, "Reference to non-existent node or label \"%s\"\n",
|
|
|
|
m->ref);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
phandle = get_node_phandle(dt, refnode);
|
2008-06-25 06:27:53 +02:00
|
|
|
*((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
|
2008-02-28 06:42:15 +01:00
|
|
|
}
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL,
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
&duplicate_node_names, &explicit_phandles);
|
|
|
|
|
2007-12-05 00:43:50 +01:00
|
|
|
static void fixup_path_references(struct check *c, struct node *dt,
|
|
|
|
struct node *node, struct property *prop)
|
|
|
|
{
|
|
|
|
struct marker *m = prop->val.markers;
|
|
|
|
struct node *refnode;
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
for_each_marker_of_type(m, REF_PATH) {
|
|
|
|
assert(m->offset <= prop->val.len);
|
|
|
|
|
|
|
|
refnode = get_node_by_ref(dt, m->ref);
|
|
|
|
if (!refnode) {
|
|
|
|
FAIL(c, "Reference to non-existent node or label \"%s\"\n",
|
|
|
|
m->ref);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
path = refnode->fullpath;
|
|
|
|
prop->val = data_insert_at_marker(prop->val, m, path,
|
|
|
|
strlen(path) + 1);
|
|
|
|
}
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
ERROR(path_references, NULL, NULL, fixup_path_references, NULL,
|
2007-12-05 00:43:50 +01:00
|
|
|
&duplicate_node_names);
|
|
|
|
|
2007-12-06 06:59:45 +01:00
|
|
|
/*
|
|
|
|
* Semantic checks
|
|
|
|
*/
|
2012-07-08 15:25:21 +02:00
|
|
|
WARNING_IF_NOT_CELL(address_cells_is_cell, "#address-cells");
|
|
|
|
WARNING_IF_NOT_CELL(size_cells_is_cell, "#size-cells");
|
|
|
|
WARNING_IF_NOT_CELL(interrupt_cells_is_cell, "#interrupt-cells");
|
2007-12-06 06:59:45 +01:00
|
|
|
|
2012-07-08 15:25:21 +02:00
|
|
|
WARNING_IF_NOT_STRING(device_type_is_string, "device_type");
|
|
|
|
WARNING_IF_NOT_STRING(model_is_string, "model");
|
|
|
|
WARNING_IF_NOT_STRING(status_is_string, "status");
|
2007-12-06 07:01:07 +01:00
|
|
|
|
2007-12-07 04:05:55 +01:00
|
|
|
static void fixup_addr_size_cells(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
node->addr_cells = -1;
|
|
|
|
node->size_cells = -1;
|
|
|
|
|
|
|
|
prop = get_property(node, "#address-cells");
|
|
|
|
if (prop)
|
|
|
|
node->addr_cells = propval_cell(prop);
|
|
|
|
|
|
|
|
prop = get_property(node, "#size-cells");
|
|
|
|
if (prop)
|
|
|
|
node->size_cells = propval_cell(prop);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
WARNING(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL,
|
|
|
|
&address_cells_is_cell, &size_cells_is_cell);
|
2007-12-07 04:05:55 +01:00
|
|
|
|
|
|
|
#define node_addr_cells(n) \
|
|
|
|
(((n)->addr_cells == -1) ? 2 : (n)->addr_cells)
|
|
|
|
#define node_size_cells(n) \
|
|
|
|
(((n)->size_cells == -1) ? 1 : (n)->size_cells)
|
|
|
|
|
|
|
|
static void check_reg_format(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
int addr_cells, size_cells, entrylen;
|
|
|
|
|
|
|
|
prop = get_property(node, "reg");
|
|
|
|
if (!prop)
|
|
|
|
return; /* No "reg", that's fine */
|
|
|
|
|
|
|
|
if (!node->parent) {
|
|
|
|
FAIL(c, "Root node has a \"reg\" property");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prop->val.len == 0)
|
|
|
|
FAIL(c, "\"reg\" property in %s is empty", node->fullpath);
|
|
|
|
|
|
|
|
addr_cells = node_addr_cells(node->parent);
|
|
|
|
size_cells = node_size_cells(node->parent);
|
|
|
|
entrylen = (addr_cells + size_cells) * sizeof(cell_t);
|
|
|
|
|
|
|
|
if ((prop->val.len % entrylen) != 0)
|
|
|
|
FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) "
|
|
|
|
"(#address-cells == %d, #size-cells == %d)",
|
|
|
|
node->fullpath, prop->val.len, addr_cells, size_cells);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_WARNING(reg_format, NULL, &addr_size_cells);
|
2007-12-07 04:05:55 +01:00
|
|
|
|
|
|
|
static void check_ranges_format(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
int c_addr_cells, p_addr_cells, c_size_cells, p_size_cells, entrylen;
|
|
|
|
|
|
|
|
prop = get_property(node, "ranges");
|
|
|
|
if (!prop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!node->parent) {
|
|
|
|
FAIL(c, "Root node has a \"ranges\" property");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_addr_cells = node_addr_cells(node->parent);
|
|
|
|
p_size_cells = node_size_cells(node->parent);
|
|
|
|
c_addr_cells = node_addr_cells(node);
|
|
|
|
c_size_cells = node_size_cells(node);
|
|
|
|
entrylen = (p_addr_cells + c_addr_cells + c_size_cells) * sizeof(cell_t);
|
|
|
|
|
|
|
|
if (prop->val.len == 0) {
|
|
|
|
if (p_addr_cells != c_addr_cells)
|
|
|
|
FAIL(c, "%s has empty \"ranges\" property but its "
|
|
|
|
"#address-cells (%d) differs from %s (%d)",
|
|
|
|
node->fullpath, c_addr_cells, node->parent->fullpath,
|
|
|
|
p_addr_cells);
|
|
|
|
if (p_size_cells != c_size_cells)
|
|
|
|
FAIL(c, "%s has empty \"ranges\" property but its "
|
|
|
|
"#size-cells (%d) differs from %s (%d)",
|
|
|
|
node->fullpath, c_size_cells, node->parent->fullpath,
|
|
|
|
p_size_cells);
|
|
|
|
} else if ((prop->val.len % entrylen) != 0) {
|
|
|
|
FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) "
|
|
|
|
"(parent #address-cells == %d, child #address-cells == %d, "
|
|
|
|
"#size-cells == %d)", node->fullpath, prop->val.len,
|
|
|
|
p_addr_cells, c_addr_cells, c_size_cells);
|
|
|
|
}
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_WARNING(ranges_format, NULL, &addr_size_cells);
|
2007-12-07 04:05:55 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Style checks
|
|
|
|
*/
|
|
|
|
static void check_avoid_default_addr_size(struct check *c, struct node *dt,
|
|
|
|
struct node *node)
|
|
|
|
{
|
|
|
|
struct property *reg, *ranges;
|
|
|
|
|
|
|
|
if (!node->parent)
|
|
|
|
return; /* Ignore root node */
|
|
|
|
|
|
|
|
reg = get_property(node, "reg");
|
|
|
|
ranges = get_property(node, "ranges");
|
|
|
|
|
|
|
|
if (!reg && !ranges)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((node->parent->addr_cells == -1))
|
|
|
|
FAIL(c, "Relying on default #address-cells value for %s",
|
|
|
|
node->fullpath);
|
|
|
|
|
|
|
|
if ((node->parent->size_cells == -1))
|
|
|
|
FAIL(c, "Relying on default #size-cells value for %s",
|
|
|
|
node->fullpath);
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells);
|
2007-12-07 04:05:55 +01:00
|
|
|
|
2007-12-07 04:06:11 +01:00
|
|
|
static void check_obsolete_chosen_interrupt_controller(struct check *c,
|
|
|
|
struct node *dt)
|
|
|
|
{
|
|
|
|
struct node *chosen;
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
chosen = get_node_by_path(dt, "/chosen");
|
|
|
|
if (!chosen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
prop = get_property(chosen, "interrupt-controller");
|
|
|
|
if (prop)
|
|
|
|
FAIL(c, "/chosen has obsolete \"interrupt-controller\" "
|
|
|
|
"property");
|
|
|
|
}
|
2012-07-08 15:25:21 +02:00
|
|
|
TREE_WARNING(obsolete_chosen_interrupt_controller, NULL);
|
2007-12-07 04:06:11 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
static struct check *check_table[] = {
|
|
|
|
&duplicate_node_names, &duplicate_property_names,
|
2008-02-27 03:45:13 +01:00
|
|
|
&node_name_chars, &node_name_format, &property_name_chars,
|
2007-12-04 23:40:23 +01:00
|
|
|
&name_is_string, &name_properties,
|
2010-02-23 09:56:41 +01:00
|
|
|
|
|
|
|
&duplicate_label,
|
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
&explicit_phandles,
|
2007-12-05 00:43:50 +01:00
|
|
|
&phandle_references, &path_references,
|
2007-12-06 06:59:45 +01:00
|
|
|
|
|
|
|
&address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
|
2007-12-06 07:01:07 +01:00
|
|
|
&device_type_is_string, &model_is_string, &status_is_string,
|
2007-12-07 04:05:55 +01:00
|
|
|
|
|
|
|
&addr_size_cells, ®_format, &ranges_format,
|
|
|
|
|
|
|
|
&avoid_default_addr_size,
|
2007-12-07 04:06:11 +01:00
|
|
|
&obsolete_chosen_interrupt_controller,
|
2012-07-08 15:25:22 +02:00
|
|
|
|
|
|
|
&always_fail,
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
};
|
2007-11-01 06:49:26 +01:00
|
|
|
|
2012-07-08 15:25:22 +02:00
|
|
|
static void enable_warning_error(struct check *c, bool warn, bool error)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Raising level, also raise it for prereqs */
|
|
|
|
if ((warn && !c->warn) || (error && !c->error))
|
|
|
|
for (i = 0; i < c->num_prereqs; i++)
|
|
|
|
enable_warning_error(c->prereq[i], warn, error);
|
|
|
|
|
|
|
|
c->warn = c->warn || warn;
|
|
|
|
c->error = c->error || error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void disable_warning_error(struct check *c, bool warn, bool error)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Lowering level, also lower it for things this is the prereq
|
|
|
|
* for */
|
|
|
|
if ((warn && c->warn) || (error && c->error)) {
|
|
|
|
for (i = 0; i < ARRAY_SIZE(check_table); i++) {
|
|
|
|
struct check *cc = check_table[i];
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; j < cc->num_prereqs; j++)
|
|
|
|
if (cc->prereq[j] == c)
|
|
|
|
disable_warning_error(cc, warn, error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
c->warn = c->warn && !warn;
|
|
|
|
c->error = c->error && !error;
|
|
|
|
}
|
|
|
|
|
2014-02-01 06:41:59 +01:00
|
|
|
void parse_checks_option(bool warn, bool error, const char *arg)
|
2012-07-08 15:25:22 +02:00
|
|
|
{
|
|
|
|
int i;
|
2014-02-01 06:41:59 +01:00
|
|
|
const char *name = arg;
|
2012-07-08 15:25:22 +02:00
|
|
|
bool enable = true;
|
|
|
|
|
2014-02-01 06:41:59 +01:00
|
|
|
if ((strncmp(arg, "no-", 3) == 0)
|
|
|
|
|| (strncmp(arg, "no_", 3) == 0)) {
|
|
|
|
name = arg + 3;
|
2012-07-08 15:25:22 +02:00
|
|
|
enable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(check_table); i++) {
|
|
|
|
struct check *c = check_table[i];
|
|
|
|
|
|
|
|
if (streq(c->name, name)) {
|
|
|
|
if (enable)
|
|
|
|
enable_warning_error(c, warn, error);
|
|
|
|
else
|
|
|
|
disable_warning_error(c, warn, error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
die("Unrecognized check name \"%s\"\n", name);
|
|
|
|
}
|
|
|
|
|
2013-10-28 11:06:53 +01:00
|
|
|
void process_checks(bool force, struct boot_info *bi)
|
2007-11-01 06:49:26 +01:00
|
|
|
{
|
2007-12-04 01:49:43 +01:00
|
|
|
struct node *dt = bi->dt;
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
int i;
|
|
|
|
int error = 0;
|
2007-11-01 06:49:26 +01:00
|
|
|
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(check_table); i++) {
|
|
|
|
struct check *c = check_table[i];
|
2007-11-01 06:49:26 +01:00
|
|
|
|
2012-07-08 15:25:21 +02:00
|
|
|
if (c->warn || c->error)
|
dtc: Flexible tree checking infrastructure (v2)
dtc: Flexible tree checking infrastructure
Here, at last, is a substantial start on revising dtc's infrastructure
for checking the tree; this is the rework I've been saying was
necessary practically since dtc was first release.
In the new model, we have a table of "check" structures, each with a
name, references to checking functions, and status variables. Each
check can (in principle) be individually switched off or on (as either
a warning or error). Checks have a list of prerequisites, so if
checks need to rely on results from earlier checks to make sense (or
even to avoid crashing) they just need to list the relevant other
checks there.
For now, only the "structural" checks and the fixups for phandle
references are converted to the new mechanism. The rather more
involved semantic checks (which is where this new mechanism will
really be useful) will have to be converted in future patches.
At present, there's no user interface for turning on/off the checks -
the -f option now forces output even if "error" level checks fail.
Again, future patches will be needed to add the fine-grained control,
but that should be quite straightforward with the infrastructure
implemented here.
Also adds a testcase for the handling of bad references, which catches
a bug encountered while developing this patch.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2007-11-22 04:38:07 +01:00
|
|
|
error = error || run_check(c, dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
if (!force) {
|
|
|
|
fprintf(stderr, "ERROR: Input tree has errors, aborting "
|
|
|
|
"(use -f to force output)\n");
|
|
|
|
exit(2);
|
|
|
|
} else if (quiet < 3) {
|
|
|
|
fprintf(stderr, "Warning: Input tree has errors, "
|
|
|
|
"output forced\n");
|
|
|
|
}
|
|
|
|
}
|
2007-11-01 06:49:26 +01:00
|
|
|
}
|