devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 3.7.0-rc2] dt: match id-table before creating platform device
@ 2012-10-23 10:30 Srinivas KANDAGATLA
  2012-10-23 13:15 ` Rob Herring
  0 siblings, 1 reply; 5+ messages in thread
From: Srinivas KANDAGATLA @ 2012-10-23 10:30 UTC (permalink / raw)
  To: grant.likely-s3s/WqlpOiPyB63q8FvJNQ,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

From: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>

As part of of_platform_populate call, the existing code iterates each
child node and then creates a platform device for each child, however
there is bug in the code which does not check the match table before
creating the platform device. This might result creating two platfrom
devices and also invoking driver probe twice, which is incorrect.

This patch moves a existing of_match_node check to start of the function
to fix the bug, doing this way will return immediately without creating
any datastructures if the child does not match the supplied match-table.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-qxv4g6HH51o@public.gmane.org>
---
 drivers/of/platform.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b80891b..1aaa560 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -367,6 +367,9 @@ static int of_platform_bus_create(struct device_node *bus,
 		return 0;
 	}
 
+	if (!of_match_node(matches, bus))
+		return 0;
+
 	auxdata = of_dev_lookup(lookup, bus);
 	if (auxdata) {
 		bus_id = auxdata->name;
@@ -379,7 +382,7 @@ static int of_platform_bus_create(struct device_node *bus,
 	}
 
 	dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
-	if (!dev || !of_match_node(matches, bus))
+	if (!dev)
 		return 0;
 
 	for_each_child_of_node(bus, child) {
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-14 22:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-23 10:30 [RFC PATCH 3.7.0-rc2] dt: match id-table before creating platform device Srinivas KANDAGATLA
2012-10-23 13:15 ` Rob Herring
2012-10-24 10:45   ` Srinivas KANDAGATLA
     [not found]   ` <5086988F.6090107-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-26  7:12     ` Srinivas KANDAGATLA
2012-11-14 22:20       ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).