mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@sifive.com>
To: devicetree@vger.kernel.org, frowand.list@gmail.com
Cc: linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	Sudip Mukherjee <sudip.mukherjee@sifive.com>,
	Jude Onyenegecha <jude.onyenegecha@sifive.com>,
	Ben Dooks <ben.dooks@sifive.com>
Subject: [PATCH] scripts/dtc: dma-ranges is a multiple of 3 cells
Date: Fri,  8 Jul 2022 18:03:59 +0100	[thread overview]
Message-ID: <20220708170359.270226-1-ben.dooks@sifive.com> (raw)

The dma-ranges property is a set 3 cells of #address-size, so don't treat
it like the ranges property when generating warnings.

Signed-off-by: Ben Dooks <ben.dooks@sifive.com>
---
 scripts/dtc/checks.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 781ba1129a8e..791b93e8e02a 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -823,7 +823,36 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
 	}
 }
 WARNING(ranges_format, check_ranges_format, "ranges", &addr_size_cells);
-WARNING(dma_ranges_format, check_ranges_format, "dma-ranges", &addr_size_cells);
+
+static void check_dma_ranges_format(struct check *c, struct dt_info *dti,
+				struct node *node)
+{
+	struct property *prop;
+	int c_size_cells, p_size_cells, entrylen;
+	const char *ranges = c->data;
+
+	prop = get_property(node, ranges);
+	if (!prop)
+		return;
+
+	if (!node->parent) {
+		FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
+			  ranges);
+		return;
+	}
+
+	c_size_cells = node_size_cells(node);
+	p_size_cells = node_size_cells(node->parent);
+	entrylen = (p_size_cells + 2 * c_size_cells) * sizeof(cell_t);
+
+	if (!is_multiple_of(prop->val.len, entrylen)) {
+		FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
+			  "(parent #address-cells == %d, "
+			  "child #address-cells == %d)", ranges, prop->val.len,
+			  p_size_cells, c_size_cells);
+	}
+}
+WARNING(dma_ranges_format, check_dma_ranges_format, "dma-ranges", &addr_size_cells);
 
 static const struct bus_type pci_bus = {
 	.name = "PCI",
-- 
2.35.1


             reply	other threads:[~2022-07-08 17:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08 17:03 Ben Dooks [this message]
2022-07-08 21:46 ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220708170359.270226-1-ben.dooks@sifive.com \
    --to=ben.dooks@sifive.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=jude.onyenegecha@sifive.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sudip.mukherjee@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®