summaryrefslogtreecommitdiffstats
path: root/drivers/of/unittest.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2016-01-04 07:13:21 -0500
committerRob Herring <robh@kernel.org>2016-01-05 10:20:40 -0500
commitd2329fb576d2c7eb0824028d9c6d3d48fb90b11a (patch)
tree7a5393b23f6c1d830b142c8b3e7d77ad304d06a3 /drivers/of/unittest.c
parentfcd71d9cc6e301bdbd71829b79e80168473ca609 (diff)
of/unittest: Show broken behaviour in the platform bus
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 <pantelis.antoniou@konsulko.com> Cc: Rob Herring <robh@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Grant Likely <grant.likely@linaro.org> [wsa: added the comment provided by Grant, rebased, and tested] Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of/unittest.c')
-rw-r--r--drivers/of/unittest.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index e16ea5717b7f..bbff09dee1cf 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -757,6 +757,11 @@ static void __init of_unittest_match_node(void)
757 } 757 }
758} 758}
759 759
760static struct resource test_bus_res = {
761 .start = 0xfffffff8,
762 .end = 0xfffffff9,
763 .flags = IORESOURCE_MEM,
764};
760static const struct platform_device_info test_bus_info = { 765static const struct platform_device_info test_bus_info = {
761 .name = "unittest-bus", 766 .name = "unittest-bus",
762}; 767};
@@ -800,6 +805,15 @@ static void __init of_unittest_platform_populate(void)
800 return; 805 return;
801 test_bus->dev.of_node = np; 806 test_bus->dev.of_node = np;
802 807
808 /*
809 * Add a dummy resource to the test bus node after it is
810 * registered to catch problems with un-inserted resources. The
811 * DT code doesn't insert the resources, and it has caused the
812 * kernel to oops in the past. This makes sure the same bug
813 * doesn't crop up again.
814 */
815 platform_device_add_resources(test_bus, &test_bus_res, 1);
816
803 of_platform_populate(np, match, NULL, &test_bus->dev); 817 of_platform_populate(np, match, NULL, &test_bus->dev);
804 for_each_child_of_node(np, child) { 818 for_each_child_of_node(np, child) {
805 for_each_child_of_node(child, grandchild) 819 for_each_child_of_node(child, grandchild)