Skip to content

Commit

Permalink
of/unittest: Show broken behaviour in the platform bus
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: Grant Likely <[email protected]>
[wsa: added the comment provided by Grant, rebased, and tested]
Signed-off-by: Wolfram Sang <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
  • Loading branch information
glikely authored and robherring committed Jan 5, 2016
1 parent fcd71d9 commit d2329fb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drivers/of/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d2329fb

Please sign in to comment.