Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Grant Likely and committed by
Rob Herring
d2329fb5 fcd71d9c

+14
+14
drivers/of/unittest.c
··· 757 757 } 758 758 } 759 759 760 + static struct resource test_bus_res = { 761 + .start = 0xfffffff8, 762 + .end = 0xfffffff9, 763 + .flags = IORESOURCE_MEM, 764 + }; 760 765 static const struct platform_device_info test_bus_info = { 761 766 .name = "unittest-bus", 762 767 }; ··· 804 799 if (rc) 805 800 return; 806 801 test_bus->dev.of_node = np; 802 + 803 + /* 804 + * Add a dummy resource to the test bus node after it is 805 + * registered to catch problems with un-inserted resources. The 806 + * DT code doesn't insert the resources, and it has caused the 807 + * kernel to oops in the past. This makes sure the same bug 808 + * doesn't crop up again. 809 + */ 810 + platform_device_add_resources(test_bus, &test_bus_res, 1); 807 811 808 812 of_platform_populate(np, match, NULL, &test_bus->dev); 809 813 for_each_child_of_node(np, child) {