Skip to contentSkip to conversation

of/unittest: Show broken behaviour in the platform bus (fwd)

PATCH New Wolfram Sang 1 participant 1 message Jan 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 of/unittest: Show broken behaviour in the platform bus (fwd)

FYI, I forgot to cc this list...

----- Forwarded message from Wolfram Sang <[email protected]> -----

Date: Mon, 4 Jan 2016 13:13:21 +0100
From: Wolfram Sang <[email protected]>
To: [email protected]
Cc: Wolfram Sang <[email protected]>, Pantelis Antoniou <[email protected]>, Rob Herring <[email protected]>, Greg Kroah-Hartman <[email protected]>, Ricardo Ribalda Delgado <[email protected]>, Rob
Herring <[email protected]>, Frank Rowand <[email protected]>, Grant Likely <[email protected]>, [email protected]
Subject: [PATCH v2] of/unittest: Show broken behaviour in the platform bus
Message-Id: <[email protected]>
X-Mailer: git-send-email 2.1.4

From: Grant Likely <[email protected]>

Add a single resource to the test bus device to exercise the platform bus code a little more. This isn't strictly a devicetree test, but it is a corner case that the devicetree runs into. Until we've got platform device unittests, it can live here. It doesn't need to be an explicit text because the kernel will oops when it is wrong.

Cc Pantelis Antoniou <[email protected]>
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Ricardo Ribalda Delgado <[email protected]>
[wsa: added the comment provided by Grant, rebased, and tested]
---
 drivers/of/unittest.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

I found this patch in one of my branches and think it is still worth applying. In v1, Rob wanted a comment added which Grant provided but never folded into the patch. I have done so now :) Note that the fix to this problem was already picked up by Rob.

drivers/of/unittest.c +14 -0
index e16ea5717b7f76..bbff09dee1cf45 100644
@@ -757,6 +757,11 @@ static void __init of_unittest_match_node(void)
 	}
 }
 
+static struct resource test_bus_res = {
+	.start = 0xfffffff8,
+	.end = 0xfffffff9,
+	.flags = IORESOURCE_MEM,
+};
 static const struct platform_device_info test_bus_info = {
 	.name = "unittest-bus",
 };
@@ -800,6 +805,15 @@ static void __init of_unittest_platform_populate(void)
 		return;
 	test_bus->dev.of_node = np;
 
+	/*
+	 * Add a dummy resource to the test bus node after it is
+	 * registered to catch problems with un-inserted resources. The
+	 * DT code doesn't insert the resources, and it has caused the
+	 * kernel to oops in the past. This makes sure the same bug
+	 * doesn't crop up again.
+	 */
+	platform_device_add_resources(test_bus, &test_bus_res, 1);
+
 	of_platform_populate(np, match, NULL, &test_bus->dev);
 	for_each_child_of_node(np, child) {
 		for_each_child_of_node(child, grandchild)
Signature · 4 lines
2.1.4


----- End forwarded message -----