Remove tree check functions

The tree check functions from the checking infrastructure aren't very
useful.  There were only two examples using them, and they're basically
equivalent to a node check which is applied only to the root node, so those
are easily replaced.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2013-10-27 19:18:06 +11:00
parent c4cb12e193
commit 2e709d158e
1 changed files with 31 additions and 36 deletions

View File

@ -40,14 +40,12 @@ enum checkstatus {
struct check; 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 (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
typedef void (*prop_check_fn)(struct check *c, struct node *dt, typedef void (*prop_check_fn)(struct check *c, struct node *dt,
struct node *node, struct property *prop); struct node *node, struct property *prop);
struct check { struct check {
const char *name; const char *name;
tree_check_fn tree_fn;
node_check_fn node_fn; node_check_fn node_fn;
prop_check_fn prop_fn; prop_check_fn prop_fn;
void *data; void *data;
@ -58,11 +56,10 @@ struct check {
struct check **prereq; struct check **prereq;
}; };
#define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...) \ #define CHECK_ENTRY(nm, nfn, pfn, d, w, e, ...) \
static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \ static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \
static struct check nm = { \ static struct check nm = { \
.name = #nm, \ .name = #nm, \
.tree_fn = (tfn), \
.node_fn = (nfn), \ .node_fn = (nfn), \
.prop_fn = (pfn), \ .prop_fn = (pfn), \
.data = (d), \ .data = (d), \
@ -72,31 +69,25 @@ struct check {
.num_prereqs = ARRAY_SIZE(nm##_prereqs), \ .num_prereqs = ARRAY_SIZE(nm##_prereqs), \
.prereq = nm##_prereqs, \ .prereq = nm##_prereqs, \
}; };
#define WARNING(nm, tfn, nfn, pfn, d, ...) \ #define WARNING(nm, nfn, pfn, d, ...) \
CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__) CHECK_ENTRY(nm, nfn, pfn, d, true, false, __VA_ARGS__)
#define ERROR(nm, tfn, nfn, pfn, d, ...) \ #define ERROR(nm, nfn, pfn, d, ...) \
CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, true, __VA_ARGS__) CHECK_ENTRY(nm, nfn, pfn, d, false, true, __VA_ARGS__)
#define CHECK(nm, tfn, nfn, pfn, d, ...) \ #define CHECK(nm, nfn, pfn, d, ...) \
CHECK_ENTRY(nm, tfn, nfn, pfn, d, false, false, __VA_ARGS__) CHECK_ENTRY(nm, nfn, pfn, d, false, false, __VA_ARGS__)
#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__)
#define TREE_CHECK(nm, d, ...) \
CHECK(nm, check_##nm, NULL, NULL, d, __VA_ARGS__)
#define NODE_WARNING(nm, d, ...) \ #define NODE_WARNING(nm, d, ...) \
WARNING(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) WARNING(nm, check_##nm, NULL, d, __VA_ARGS__)
#define NODE_ERROR(nm, d, ...) \ #define NODE_ERROR(nm, d, ...) \
ERROR(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) ERROR(nm, check_##nm, NULL, d, __VA_ARGS__)
#define NODE_CHECK(nm, d, ...) \ #define NODE_CHECK(nm, d, ...) \
CHECK(nm, NULL, check_##nm, NULL, d, __VA_ARGS__) CHECK(nm, check_##nm, NULL, d, __VA_ARGS__)
#define PROP_WARNING(nm, d, ...) \ #define PROP_WARNING(nm, d, ...) \
WARNING(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) WARNING(nm, NULL, check_##nm, d, __VA_ARGS__)
#define PROP_ERROR(nm, d, ...) \ #define PROP_ERROR(nm, d, ...) \
ERROR(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) ERROR(nm, NULL, check_##nm, d, __VA_ARGS__)
#define PROP_CHECK(nm, d, ...) \ #define PROP_CHECK(nm, d, ...) \
CHECK(nm, NULL, NULL, check_##nm, d, __VA_ARGS__) CHECK(nm, NULL, check_##nm, d, __VA_ARGS__)
#ifdef __GNUC__ #ifdef __GNUC__
static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
@ -170,8 +161,6 @@ static bool run_check(struct check *c, struct node *dt)
if (c->node_fn || c->prop_fn) if (c->node_fn || c->prop_fn)
check_nodes_props(c, dt, dt); check_nodes_props(c, dt, dt);
if (c->tree_fn)
c->tree_fn(c, dt);
if (c->status == UNCHECKED) if (c->status == UNCHECKED)
c->status = PASSED; c->status = PASSED;
@ -189,11 +178,12 @@ out:
*/ */
/* A check which always fails, for testing purposes only */ /* A check which always fails, for testing purposes only */
static inline void check_always_fail(struct check *c, struct node *dt) static inline void check_always_fail(struct check *c, struct node *dt,
struct node *node)
{ {
FAIL(c, "always_fail check"); FAIL(c, "always_fail check");
} }
TREE_CHECK(always_fail, NULL); NODE_CHECK(always_fail, NULL);
static void check_is_string(struct check *c, struct node *root, static void check_is_string(struct check *c, struct node *root,
struct node *node) struct node *node)
@ -210,9 +200,9 @@ static void check_is_string(struct check *c, struct node *root,
propname, node->fullpath); propname, node->fullpath);
} }
#define WARNING_IF_NOT_STRING(nm, propname) \ #define WARNING_IF_NOT_STRING(nm, propname) \
WARNING(nm, NULL, check_is_string, NULL, (propname)) WARNING(nm, check_is_string, NULL, (propname))
#define ERROR_IF_NOT_STRING(nm, propname) \ #define ERROR_IF_NOT_STRING(nm, propname) \
ERROR(nm, NULL, check_is_string, NULL, (propname)) ERROR(nm, check_is_string, NULL, (propname))
static void check_is_cell(struct check *c, struct node *root, static void check_is_cell(struct check *c, struct node *root,
struct node *node) struct node *node)
@ -229,9 +219,9 @@ static void check_is_cell(struct check *c, struct node *root,
propname, node->fullpath); propname, node->fullpath);
} }
#define WARNING_IF_NOT_CELL(nm, propname) \ #define WARNING_IF_NOT_CELL(nm, propname) \
WARNING(nm, NULL, check_is_cell, NULL, (propname)) WARNING(nm, check_is_cell, NULL, (propname))
#define ERROR_IF_NOT_CELL(nm, propname) \ #define ERROR_IF_NOT_CELL(nm, propname) \
ERROR(nm, NULL, check_is_cell, NULL, (propname)) ERROR(nm, check_is_cell, NULL, (propname))
/* /*
* Structural check functions * Structural check functions
@ -382,7 +372,7 @@ static void check_duplicate_label_prop(struct check *c, struct node *dt,
for_each_marker_of_type(m, LABEL) for_each_marker_of_type(m, LABEL)
check_duplicate_label(c, dt, m->ref, node, prop, m); check_duplicate_label(c, dt, m->ref, node, prop, m);
} }
ERROR(duplicate_label, NULL, check_duplicate_label_node, ERROR(duplicate_label, check_duplicate_label_node,
check_duplicate_label_prop, NULL); check_duplicate_label_prop, NULL);
static void check_explicit_phandles(struct check *c, struct node *root, static void check_explicit_phandles(struct check *c, struct node *root,
@ -499,7 +489,7 @@ static void fixup_phandle_references(struct check *c, struct node *dt,
*((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
} }
} }
ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL, ERROR(phandle_references, NULL, fixup_phandle_references, NULL,
&duplicate_node_names, &explicit_phandles); &duplicate_node_names, &explicit_phandles);
static void fixup_path_references(struct check *c, struct node *dt, static void fixup_path_references(struct check *c, struct node *dt,
@ -524,7 +514,7 @@ static void fixup_path_references(struct check *c, struct node *dt,
strlen(path) + 1); strlen(path) + 1);
} }
} }
ERROR(path_references, NULL, NULL, fixup_path_references, NULL, ERROR(path_references, NULL, fixup_path_references, NULL,
&duplicate_node_names); &duplicate_node_names);
/* /*
@ -554,7 +544,7 @@ static void fixup_addr_size_cells(struct check *c, struct node *dt,
if (prop) if (prop)
node->size_cells = propval_cell(prop); node->size_cells = propval_cell(prop);
} }
WARNING(addr_size_cells, NULL, fixup_addr_size_cells, NULL, NULL, WARNING(addr_size_cells, fixup_addr_size_cells, NULL, NULL,
&address_cells_is_cell, &size_cells_is_cell); &address_cells_is_cell, &size_cells_is_cell);
#define node_addr_cells(n) \ #define node_addr_cells(n) \
@ -660,11 +650,16 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells); NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells);
static void check_obsolete_chosen_interrupt_controller(struct check *c, static void check_obsolete_chosen_interrupt_controller(struct check *c,
struct node *dt) struct node *dt,
struct node *node)
{ {
struct node *chosen; struct node *chosen;
struct property *prop; struct property *prop;
if (node != dt)
return;
chosen = get_node_by_path(dt, "/chosen"); chosen = get_node_by_path(dt, "/chosen");
if (!chosen) if (!chosen)
return; return;
@ -674,7 +669,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
FAIL(c, "/chosen has obsolete \"interrupt-controller\" " FAIL(c, "/chosen has obsolete \"interrupt-controller\" "
"property"); "property");
} }
TREE_WARNING(obsolete_chosen_interrupt_controller, NULL); NODE_WARNING(obsolete_chosen_interrupt_controller, NULL);
static struct check *check_table[] = { static struct check *check_table[] = {
&duplicate_node_names, &duplicate_property_names, &duplicate_node_names, &duplicate_property_names,