[PATCH] of: unittest: Use bigger address cells to catch parser regressions

Nicolas Saenz Julienne nsaenzjulienne at suse.de
Mon Aug 3 10:25:47 EDT 2020


Getting address and size cells for dma-ranges/ranges parsing is tricky
and shouldn't rely on the node's count_cells() method. The function
starts looking for cells on the parent node, as its supposed to work
with device nodes, which doesn't work when input with bus nodes, as
generally done when parsing ranges.

Add test to catch regressions on that specific quirk as developers will
be tempted to edit it out in favor of the default method.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne at suse.de>
---
 drivers/of/unittest-data/tests-address.dtsi | 10 +++++-----
 drivers/of/unittest.c                       |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/of/unittest-data/tests-address.dtsi b/drivers/of/unittest-data/tests-address.dtsi
index 3fe5d3987beb..6604a52bf6cb 100644
--- a/drivers/of/unittest-data/tests-address.dtsi
+++ b/drivers/of/unittest-data/tests-address.dtsi
@@ -23,13 +23,13 @@ device at 70000000 {
 			};
 
 			bus at 80000000 {
-				#address-cells = <1>;
-				#size-cells = <1>;
-				ranges = <0x0 0x80000000 0x100000>;
-				dma-ranges = <0x10000000 0x0 0x40000000>;
+				#address-cells = <2>;
+				#size-cells = <2>;
+				ranges = <0x0 0x0 0x80000000 0x0 0x100000>;
+				dma-ranges = <0x1 0x0 0x0 0x20 0x0>;
 
 				device at 1000 {
-					reg = <0x1000 0x1000>;
+					reg = <0x0 0x1000 0x0 0x1000>;
 				};
 			};
 
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 398de04fd19c..9b7e84bdc7d4 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -900,7 +900,7 @@ static void __init of_unittest_parse_dma_ranges(void)
 	of_unittest_dma_ranges_one("/testcase-data/address-tests/device at 70000000",
 		0x0, 0x20000000, 0x40000000);
 	of_unittest_dma_ranges_one("/testcase-data/address-tests/bus at 80000000/device at 1000",
-		0x10000000, 0x20000000, 0x40000000);
+		0x100000000, 0x20000000, 0x2000000000);
 	of_unittest_dma_ranges_one("/testcase-data/address-tests/pci at 90000000",
 		0x80000000, 0x20000000, 0x10000000);
 }
-- 
2.28.0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-rpi-kernel/attachments/20200803/41f52aad/attachment.sig>


More information about the linux-rpi-kernel mailing list