summaryrefslogtreecommitdiff
path: root/drivers/of/platform.c
diff options
context:
space:
mode:
authorJia Hongtao <B38951@freescale.com>2012-05-03 09:02:39 (GMT)
committerFleming Andrew-AFLEMING <AFLEMING@freescale.com>2013-04-09 22:58:31 (GMT)
commitb3bee25876d4ca2ae75549b3402331bf24905a52 (patch)
tree983f3a2d7adf9252ab1743ed77da0cd000392d67 /drivers/of/platform.c
parented9118a6c9c75188464ae6b5dbb377ac47e1a751 (diff)
downloadlinux-fsl-qoriq-b3bee25876d4ca2ae75549b3402331bf24905a52.tar.xz
Avoid duplicate probe for of platform devices
PCI controller driver is now a platform driver and the PCI of platform devices need to be created earlier in the arch_initcall stage according to the original timing of calling fsl_add_bridge(). So we have to probe PCI devices separately from other devices. But probing more than once may cause duplication warning. We add check if the device have already probed before probing to avoid duplication. Signed-off-by: Jia Hongtao <B38951@freescale.com> Signed-off-by: Li Yang <leoli@freescale.com> Change-Id: If926bb6d57af8353ef154a7225411a6465c13711 Reviewed-on: http://git.am.freescale.net:8181/1176 Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com> Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r--drivers/of/platform.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b80891b..19c5e68 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -148,6 +148,18 @@ struct platform_device *of_device_alloc(struct device_node *np,
if (!dev)
return NULL;
+ dev->dev.of_node = of_node_get(np);
+ if (bus_id)
+ dev_set_name(&dev->dev, "%s", bus_id);
+ else
+ of_device_make_bus_id(&dev->dev);
+
+ if (kset_find_obj(dev->dev.kobj.kset, kobject_name(&dev->dev.kobj))) {
+ kfree(dev);
+ of_node_put(np);
+ return NULL;
+ }
+
/* count the io and irq resources */
if (of_can_translate_address(np))
while (of_address_to_resource(np, num_reg, &temp_res) == 0)
@@ -171,17 +183,11 @@ struct platform_device *of_device_alloc(struct device_node *np,
WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq);
}
- dev->dev.of_node = of_node_get(np);
#if defined(CONFIG_MICROBLAZE)
dev->dev.dma_mask = &dev->archdata.dma_mask;
#endif
dev->dev.parent = parent;
- if (bus_id)
- dev_set_name(&dev->dev, "%s", bus_id);
- else
- of_device_make_bus_id(&dev->dev);
-
return dev;
}
EXPORT_SYMBOL(of_device_alloc);