Skip to content

Commit

Permalink
dtc: Migrate "string property" checks to new framework
Browse files Browse the repository at this point in the history
This patch converts to the new tree checking framework those checks
which verify that certain properties (device_type, model) have a
string value, when present.

Signed-off-by: David Gibson <[email protected]>
  • Loading branch information
dgibson authored and Jon Loeliger committed Dec 6, 2007
1 parent c21acab commit faf037f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
18 changes: 5 additions & 13 deletions checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,18 @@ 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);

CHECK_IS_STRING(device_type_is_string, "device_type", WARN);
CHECK_IS_STRING(model_is_string, "model", WARN);
CHECK_IS_STRING(status_is_string, "status", WARN);

static struct check *check_table[] = {
&duplicate_node_names, &duplicate_property_names,
&name_is_string, &name_properties,
&explicit_phandles,
&phandle_references, &path_references,

&address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell,
&device_type_is_string, &model_is_string, &status_is_string,
};

int check_semantics(struct node *dt, int outversion, int boot_cpuid_phys);
Expand Down Expand Up @@ -418,24 +423,11 @@ static int must_be_cells(struct property *prop, struct node *node)
return 1;
}

static int must_be_string(struct property *prop, struct node *node)
{
if (! data_is_one_string(prop->val)) {
ERRMSG("\"%s\" property in %s is not a string\n",
prop->name, node->fullpath);
return 0;
}

return 1;
}

static struct {
char *propname;
int (*check_fn)(struct property *prop, struct node *node);
} prop_checker_table[] = {
{"reg", must_be_cells},
{"model", must_be_string},
{"device_type", must_be_string},
};

static int check_properties(struct node *node)
Expand Down
7 changes: 7 additions & 0 deletions tests/bad-string-props.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/dts-v1/;

/ {
device_type = <0xdeadbeef>;
model = <0xdeadbeef>;
status = <0xdeadbeef>;
};
2 changes: 2 additions & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ dtc_tests () {
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
run_test dtc-checkfails.sh device_type_is_string model_is_string status_is_string -- -I dts -O dtb bad-string-props.dts

}

while getopts "vt:m" ARG ; do
Expand Down

0 comments on commit faf037f

Please sign in to comment.