From 3aa0582fdb824139630298880fbf78d4ac774d3c Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Thu, 28 Sep 2017 11:45:59 +0100 Subject: of: platform: populate /firmware/ node from of_platform_default_populate_init() Since "/firmware" does not have its own "compatible" property as it's just collection of nodes representing firmware interface, it's sub-nodes are not populated during system initialization. Currently different firmware drivers search the /firmware/ node and populate the sub-node devices selectively. Instead we can populate the /firmware/ node during init to avoid more drivers continuing to populate the devices selectively. To generalize the solution this patch populates the /firmware/ node explicitly from of_platform_default_populate_init(). Cc: Arnd Bergmann Cc: Rob Herring Signed-off-by: Sudeep Holla Acked-by: Rob Herring Acked-by: Bjorn Andersson Tested-by: Bjorn Andersson Signed-off-by: Andy Gross --- drivers/of/platform.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/of') diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b7cf84b29737..78cfb15c7890 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -518,6 +518,10 @@ static int __init of_platform_default_populate_init(void) for_each_matching_node(node, reserved_mem_matches) of_platform_device_create(node, NULL, NULL); + node = of_find_node_by_path("/firmware"); + if (node) + of_platform_populate(node, NULL, NULL, NULL); + /* Populate everything else. */ of_platform_default_populate(NULL, NULL, NULL); -- cgit v1.2.3 From e2105ca8beb0c776a52ae8d18bc6b564745de2e4 Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Thu, 18 Jan 2018 10:43:39 +0000 Subject: of: platform: fix OF node refcount leak We need to call of_node_put() for device nodes obtained with of_find_node_by_path(). Fixes: 3aa0582fdb82 ("of: platform: populate /firmware/ node from of_platform_default_populate_init()") Reported-by: Loys Ollivier Cc: Frank Rowand Signed-off-by: Sudeep Holla Acked-by: Rob Herring Signed-off-by: Andy Gross Signed-off-by: Arnd Bergmann --- drivers/of/platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 78cfb15c7890..faf7d87f8833 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -519,8 +519,10 @@ static int __init of_platform_default_populate_init(void) of_platform_device_create(node, NULL, NULL); node = of_find_node_by_path("/firmware"); - if (node) + if (node) { of_platform_populate(node, NULL, NULL, NULL); + of_node_put(node); + } /* Populate everything else. */ of_platform_default_populate(NULL, NULL, NULL); -- cgit v1.2.3