Simplify check field and macro names

Now that "node" checks are the only type of checks, simplify some names
accordingly.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2013-11-01 23:57:17 +11:00
parent 9d97527a86
commit 1ee0ae24ea

View file

@ -40,11 +40,11 @@ enum checkstatus {
struct check; struct check;
typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node); typedef void (*check_fn)(struct check *c, struct node *dt, struct node *node);
struct check { struct check {
const char *name; const char *name;
node_check_fn node_fn; check_fn fn;
void *data; void *data;
bool warn, error; bool warn, error;
enum checkstatus status; enum checkstatus status;
@ -53,31 +53,24 @@ struct check {
struct check **prereq; struct check **prereq;
}; };
#define CHECK_ENTRY(nm, nfn, d, w, e, ...) \ #define CHECK_ENTRY(_nm, _fn, _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, \
.node_fn = (nfn), \ .fn = (_fn), \
.data = (d), \ .data = (_d), \
.warn = (w), \ .warn = (_w), \
.error = (e), \ .error = (_e), \
.status = UNCHECKED, \ .status = UNCHECKED, \
.num_prereqs = ARRAY_SIZE(nm##_prereqs), \ .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \
.prereq = nm##_prereqs, \ .prereq = _nm##_prereqs, \
}; };
#define WARNING(nm, nfn, d, ...) \ #define WARNING(_nm, _fn, _d, ...) \
CHECK_ENTRY(nm, nfn, d, true, false, __VA_ARGS__) CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__)
#define ERROR(nm, nfn, d, ...) \ #define ERROR(_nm, _fn, _d, ...) \
CHECK_ENTRY(nm, nfn, d, false, true, __VA_ARGS__) CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__)
#define CHECK(nm, nfn, d, ...) \ #define CHECK(_nm, _fn, _d, ...) \
CHECK_ENTRY(nm, nfn, d, false, false, __VA_ARGS__) CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
#define NODE_WARNING(nm, d, ...) \
WARNING(nm, check_##nm, d, __VA_ARGS__)
#define NODE_ERROR(nm, d, ...) \
ERROR(nm, check_##nm, d, __VA_ARGS__)
#define NODE_CHECK(nm, d, ...) \
CHECK(nm, 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)));
@ -109,8 +102,8 @@ static void check_nodes_props(struct check *c, struct node *dt, struct node *nod
struct node *child; struct node *child;
TRACE(c, "%s", node->fullpath); TRACE(c, "%s", node->fullpath);
if (c->node_fn) if (c->fn)
c->node_fn(c, dt, node); c->fn(c, dt, node);
for_each_child(node, child) for_each_child(node, child)
check_nodes_props(c, dt, child); check_nodes_props(c, dt, child);
@ -141,8 +134,7 @@ static bool run_check(struct check *c, struct node *dt)
if (c->status != UNCHECKED) if (c->status != UNCHECKED)
goto out; goto out;
if (c->node_fn) check_nodes_props(c, dt, dt);
check_nodes_props(c, dt, dt);
if (c->status == UNCHECKED) if (c->status == UNCHECKED)
c->status = PASSED; c->status = PASSED;
@ -166,7 +158,7 @@ static inline void check_always_fail(struct check *c, struct node *dt,
{ {
FAIL(c, "always_fail check"); FAIL(c, "always_fail check");
} }
NODE_CHECK(always_fail, NULL); CHECK(always_fail, 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)
@ -223,7 +215,7 @@ static void check_duplicate_node_names(struct check *c, struct node *dt,
FAIL(c, "Duplicate node name %s", FAIL(c, "Duplicate node name %s",
child->fullpath); child->fullpath);
} }
NODE_ERROR(duplicate_node_names, NULL); ERROR(duplicate_node_names, check_duplicate_node_names, NULL);
static void check_duplicate_property_names(struct check *c, struct node *dt, static void check_duplicate_property_names(struct check *c, struct node *dt,
struct node *node) struct node *node)
@ -240,7 +232,7 @@ static void check_duplicate_property_names(struct check *c, struct node *dt,
} }
} }
} }
NODE_ERROR(duplicate_property_names, NULL); ERROR(duplicate_property_names, check_duplicate_property_names, NULL);
#define LOWERCASE "abcdefghijklmnopqrstuvwxyz" #define LOWERCASE "abcdefghijklmnopqrstuvwxyz"
#define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -256,7 +248,7 @@ static void check_node_name_chars(struct check *c, struct node *dt,
FAIL(c, "Bad character '%c' in node %s", FAIL(c, "Bad character '%c' in node %s",
node->name[n], node->fullpath); node->name[n], node->fullpath);
} }
NODE_ERROR(node_name_chars, PROPNODECHARS "@"); ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@");
static void check_node_name_format(struct check *c, struct node *dt, static void check_node_name_format(struct check *c, struct node *dt,
struct node *node) struct node *node)
@ -265,7 +257,7 @@ static void check_node_name_format(struct check *c, struct node *dt,
FAIL(c, "Node %s has multiple '@' characters in name", FAIL(c, "Node %s has multiple '@' characters in name",
node->fullpath); node->fullpath);
} }
NODE_ERROR(node_name_format, NULL, &node_name_chars); ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars);
static void check_unit_address_vs_reg(struct check *c, struct node *dt, static void check_unit_address_vs_reg(struct check *c, struct node *dt,
struct node *node) struct node *node)
@ -289,7 +281,7 @@ static void check_unit_address_vs_reg(struct check *c, struct node *dt,
node->fullpath); node->fullpath);
} }
} }
NODE_WARNING(unit_address_vs_reg, NULL); WARNING(unit_address_vs_reg, check_unit_address_vs_reg, NULL);
static void check_property_name_chars(struct check *c, struct node *dt, static void check_property_name_chars(struct check *c, struct node *dt,
struct node *node) struct node *node)
@ -304,7 +296,7 @@ static void check_property_name_chars(struct check *c, struct node *dt,
prop->name[n], prop->name, node->fullpath); prop->name[n], prop->name, node->fullpath);
} }
} }
NODE_ERROR(property_name_chars, PROPNODECHARS); ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS);
#define DESCLABEL_FMT "%s%s%s%s%s" #define DESCLABEL_FMT "%s%s%s%s%s"
#define DESCLABEL_ARGS(node,prop,mark) \ #define DESCLABEL_ARGS(node,prop,mark) \
@ -439,7 +431,7 @@ static void check_explicit_phandles(struct check *c, struct node *root,
node->phandle = phandle; node->phandle = phandle;
} }
NODE_ERROR(explicit_phandles, NULL); ERROR(explicit_phandles, check_explicit_phandles, NULL);
static void check_name_properties(struct check *c, struct node *root, static void check_name_properties(struct check *c, struct node *root,
struct node *node) struct node *node)
@ -469,7 +461,7 @@ static void check_name_properties(struct check *c, struct node *root,
} }
} }
ERROR_IF_NOT_STRING(name_is_string, "name"); ERROR_IF_NOT_STRING(name_is_string, "name");
NODE_ERROR(name_properties, NULL, &name_is_string); ERROR(name_properties, check_name_properties, NULL, &name_is_string);
/* /*
* Reference fixup functions * Reference fixup functions
@ -593,7 +585,7 @@ static void check_reg_format(struct check *c, struct node *dt,
"(#address-cells == %d, #size-cells == %d)", "(#address-cells == %d, #size-cells == %d)",
node->fullpath, prop->val.len, addr_cells, size_cells); node->fullpath, prop->val.len, addr_cells, size_cells);
} }
NODE_WARNING(reg_format, NULL, &addr_size_cells); WARNING(reg_format, check_reg_format, NULL, &addr_size_cells);
static void check_ranges_format(struct check *c, struct node *dt, static void check_ranges_format(struct check *c, struct node *dt,
struct node *node) struct node *node)
@ -634,7 +626,7 @@ static void check_ranges_format(struct check *c, struct node *dt,
p_addr_cells, c_addr_cells, c_size_cells); p_addr_cells, c_addr_cells, c_size_cells);
} }
} }
NODE_WARNING(ranges_format, NULL, &addr_size_cells); WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
/* /*
* Style checks * Style checks
@ -661,7 +653,8 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
FAIL(c, "Relying on default #size-cells value for %s", FAIL(c, "Relying on default #size-cells value for %s",
node->fullpath); node->fullpath);
} }
NODE_WARNING(avoid_default_addr_size, NULL, &addr_size_cells); WARNING(avoid_default_addr_size, check_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,
@ -683,7 +676,8 @@ 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");
} }
NODE_WARNING(obsolete_chosen_interrupt_controller, NULL); WARNING(obsolete_chosen_interrupt_controller,
check_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,