dtc: Migrate "one cell" checks to new framework
This patch converts to the new tree checking framework those checks which verify that certain properties (#address-cells and #size-cells) are exactly one cell in size, when present. We also drop the old-style check for "linux,phandle" being one cell, since that is already implied in the the existing new-style checks on the linux,phandle property. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>main
parent
5ba0086bfd
commit
c21acabc40
40
checks.c
40
checks.c
|
@ -190,6 +190,23 @@ static void check_is_string(struct check *c, struct node *root,
|
||||||
#define CHECK_IS_STRING(nm, propname, lvl) \
|
#define CHECK_IS_STRING(nm, propname, lvl) \
|
||||||
CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl))
|
CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl))
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#define CHECK_IS_CELL(nm, propname, lvl) \
|
||||||
|
CHECK(nm, NULL, check_is_cell, NULL, (propname), (lvl))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structural check functions
|
* Structural check functions
|
||||||
*/
|
*/
|
||||||
|
@ -327,11 +344,20 @@ static void fixup_path_references(struct check *c, struct node *dt,
|
||||||
CHECK(path_references, NULL, NULL, fixup_path_references, NULL, ERROR,
|
CHECK(path_references, NULL, NULL, fixup_path_references, NULL, ERROR,
|
||||||
&duplicate_node_names);
|
&duplicate_node_names);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Semantic checks
|
||||||
|
*/
|
||||||
|
CHECK_IS_CELL(address_cells_is_cell, "#address-cells", WARN);
|
||||||
|
CHECK_IS_CELL(size_cells_is_cell, "#size-cells", WARN);
|
||||||
|
CHECK_IS_CELL(interrupt_cells_is_cell, "#interrupt-cells", WARN);
|
||||||
|
|
||||||
static struct check *check_table[] = {
|
static struct check *check_table[] = {
|
||||||
&duplicate_node_names, &duplicate_property_names,
|
&duplicate_node_names, &duplicate_property_names,
|
||||||
&name_is_string, &name_properties,
|
&name_is_string, &name_properties,
|
||||||
&explicit_phandles,
|
&explicit_phandles,
|
||||||
&phandle_references, &path_references,
|
&phandle_references, &path_references,
|
||||||
|
|
||||||
|
&address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
|
||||||
};
|
};
|
||||||
|
|
||||||
int check_semantics(struct node *dt, int outversion, int boot_cpuid_phys);
|
int check_semantics(struct node *dt, int outversion, int boot_cpuid_phys);
|
||||||
|
@ -381,17 +407,6 @@ void process_checks(int force, struct boot_info *bi,
|
||||||
|
|
||||||
#define DO_ERR(...) do {ERRMSG(__VA_ARGS__); ok = 0; } while (0)
|
#define DO_ERR(...) do {ERRMSG(__VA_ARGS__); ok = 0; } while (0)
|
||||||
|
|
||||||
static int must_be_one_cell(struct property *prop, struct node *node)
|
|
||||||
{
|
|
||||||
if (prop->val.len != sizeof(cell_t)) {
|
|
||||||
ERRMSG("\"%s\" property in %s has the wrong length (should be 1 cell)\n",
|
|
||||||
prop->name, node->fullpath);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int must_be_cells(struct property *prop, struct node *node)
|
static int must_be_cells(struct property *prop, struct node *node)
|
||||||
{
|
{
|
||||||
if ((prop->val.len % sizeof(cell_t)) != 0) {
|
if ((prop->val.len % sizeof(cell_t)) != 0) {
|
||||||
|
@ -418,9 +433,6 @@ static struct {
|
||||||
char *propname;
|
char *propname;
|
||||||
int (*check_fn)(struct property *prop, struct node *node);
|
int (*check_fn)(struct property *prop, struct node *node);
|
||||||
} prop_checker_table[] = {
|
} prop_checker_table[] = {
|
||||||
{"linux,phandle", must_be_one_cell},
|
|
||||||
{"#address-cells", must_be_one_cell},
|
|
||||||
{"#size-cells", must_be_one_cell},
|
|
||||||
{"reg", must_be_cells},
|
{"reg", must_be_cells},
|
||||||
{"model", must_be_string},
|
{"model", must_be_string},
|
||||||
{"device_type", must_be_string},
|
{"device_type", must_be_string},
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
/dts-v1/;
|
||||||
|
|
||||||
|
/ {
|
||||||
|
#address-cells = "badthing";
|
||||||
|
#size-cells = "badthing";
|
||||||
|
#interrupt-cells = "badthing";
|
||||||
|
};
|
|
@ -166,6 +166,8 @@ dtc_tests () {
|
||||||
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
|
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-node-ref.dts
|
||||||
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
|
run_test dtc-checkfails.sh phandle_references -- -I dts -O dtb nonexist-label-ref.dts
|
||||||
run_test dtc-checkfails.sh name_properties -- -I dts -O dtb bad-name-property.dts
|
run_test dtc-checkfails.sh name_properties -- -I dts -O dtb bad-name-property.dts
|
||||||
|
|
||||||
|
run_test dtc-checkfails.sh address_cells_is_cell size_cells_is_cell interrupt_cells_is_cell -- -I dts -O dtb bad-ncells.dts
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "vt:m" ARG ; do
|
while getopts "vt:m" ARG ; do
|
||||||
|
|
Loading…
Reference in New Issue