Skip to content

Commit

Permalink
checks: Add 'dma-ranges' check
Browse files Browse the repository at this point in the history
Generalize the existing 'ranges' check to also work for 'dma-ranges'
which has the same parsing requirements.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20200303193931.1653-1-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
robherring authored and dgibson committed Mar 3, 2020
1 parent e5c92a4 commit 76b43dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
23 changes: 13 additions & 10 deletions checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,15 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
{
struct property *prop;
int c_addr_cells, p_addr_cells, c_size_cells, p_size_cells, entrylen;
const char *ranges = c->data;

prop = get_property(node, "ranges");
prop = get_property(node, ranges);
if (!prop)
return;

if (!node->parent) {
FAIL_PROP(c, dti, node, prop, "Root node has a \"ranges\" property");
FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
ranges);
return;
}

Expand All @@ -783,23 +785,24 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,

if (prop->val.len == 0) {
if (p_addr_cells != c_addr_cells)
FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
"#address-cells (%d) differs from %s (%d)",
c_addr_cells, node->parent->fullpath,
ranges, c_addr_cells, node->parent->fullpath,
p_addr_cells);
if (p_size_cells != c_size_cells)
FAIL_PROP(c, dti, node, prop, "empty \"ranges\" property but its "
FAIL_PROP(c, dti, node, prop, "empty \"%s\" property but its "
"#size-cells (%d) differs from %s (%d)",
c_size_cells, node->parent->fullpath,
ranges, c_size_cells, node->parent->fullpath,
p_size_cells);
} else if ((prop->val.len % entrylen) != 0) {
FAIL_PROP(c, dti, node, prop, "\"ranges\" property has invalid length (%d bytes) "
FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
"(parent #address-cells == %d, child #address-cells == %d, "
"#size-cells == %d)", prop->val.len,
"#size-cells == %d)", ranges, prop->val.len,
p_addr_cells, c_addr_cells, c_size_cells);
}
}
WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
WARNING(ranges_format, check_ranges_format, "ranges", &addr_size_cells);
WARNING(dma_ranges_format, check_ranges_format, "dma-ranges", &addr_size_cells);

static const struct bus_type pci_bus = {
.name = "PCI",
Expand Down Expand Up @@ -1780,7 +1783,7 @@ static struct check *check_table[] = {
&property_name_chars_strict,
&node_name_chars_strict,

&addr_size_cells, &reg_format, &ranges_format,
&addr_size_cells, &reg_format, &ranges_format, &dma_ranges_format,

&unit_address_vs_reg,
&unit_address_format,
Expand Down
12 changes: 12 additions & 0 deletions tests/bad-dma-ranges.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/dts-v1/;

/ {
#address-cells = <2>;
#size-cells = <2>;
node {
#address-cells = <1>;
#size-cells = <1>;
ranges;
dma-ranges = <0 0 0 0 0>;
};
};
1 change: 1 addition & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ dtc_tests () {
check_tests "$SRCDIR/bad-reg-ranges.dts" reg_format ranges_format
check_tests "$SRCDIR/bad-empty-ranges.dts" ranges_format
check_tests "$SRCDIR/reg-ranges-root.dts" reg_format ranges_format
check_tests "$SRCDIR/bad-dma-ranges.dts" dma_ranges_format
check_tests "$SRCDIR/default-addr-size.dts" avoid_default_addr_size
check_tests "$SRCDIR/obsolete-chosen-interrupt-controller.dts" obsolete_chosen_interrupt_controller
check_tests "$SRCDIR/reg-without-unit-addr.dts" unit_address_vs_reg
Expand Down

0 comments on commit 76b43dc

Please sign in to comment.