diff options
author | 2017-12-12 16:46:25 -0600 | |
---|---|---|
committer | 2017-12-13 20:22:56 +1100 | |
commit | 8fe94fd6f19f9065b9147d364d35167a3c9b016a (patch) | |
tree | fb3b9b98c50f46cdc7061db82297f2bb7d540536 /checks.c | |
parent | 6c573081960442dbec11a9ae96daedc75a9d84a7 (diff) |
checks: add string list check
Add a check for string list properties with compatible being the first
check.
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'checks.c')
-rw-r--r-- | checks.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -179,6 +179,36 @@ static void check_is_string(struct check *c, struct dt_info *dti, #define ERROR_IF_NOT_STRING(nm, propname) \ ERROR(nm, check_is_string, (propname)) +static void check_is_string_list(struct check *c, struct dt_info *dti, + struct node *node) +{ + int rem, l; + struct property *prop; + char *propname = c->data; + char *str; + + prop = get_property(node, propname); + if (!prop) + return; /* Not present, assumed ok */ + + str = prop->val.val; + rem = prop->val.len; + while (rem > 0) { + l = strnlen(str, rem); + if (l == rem) { + FAIL(c, dti, "\"%s\" property in %s is not a string list", + propname, node->fullpath); + break; + } + rem -= l + 1; + str += l + 1; + } +} +#define WARNING_IF_NOT_STRING_LIST(nm, propname) \ + WARNING(nm, check_is_string_list, (propname)) +#define ERROR_IF_NOT_STRING_LIST(nm, propname) \ + ERROR(nm, check_is_string_list, (propname)) + static void check_is_cell(struct check *c, struct dt_info *dti, struct node *node) { @@ -588,6 +618,8 @@ WARNING_IF_NOT_STRING(model_is_string, "model"); WARNING_IF_NOT_STRING(status_is_string, "status"); WARNING_IF_NOT_STRING(label_is_string, "label"); +WARNING_IF_NOT_STRING_LIST(compatible_is_string_list, "compatible"); + static void fixup_addr_size_cells(struct check *c, struct dt_info *dti, struct node *node) { @@ -1239,6 +1271,8 @@ static struct check *check_table[] = { &device_type_is_string, &model_is_string, &status_is_string, &label_is_string, + &compatible_is_string_list, + &property_name_chars_strict, &node_name_chars_strict, |