aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/microblaze/kernel/of_platform.c11
-rw-r--r--arch/microblaze/kernel/setup.c6
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c8
-rw-r--r--arch/powerpc/kernel/of_platform.c12
-rw-r--r--arch/powerpc/kernel/setup-common.c7
-rw-r--r--arch/powerpc/platforms/cell/beat_iommu.c2
-rw-r--r--arch/powerpc/platforms/cell/iommu.c2
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c7
-rw-r--r--arch/sparc/kernel/of_device_32.c21
-rw-r--r--arch/sparc/kernel/of_device_64.c21
-rw-r--r--arch/sparc/kernel/of_device_common.c3
-rw-r--r--drivers/base/platform.c6
-rw-r--r--drivers/of/device.c5
-rw-r--r--drivers/of/platform.c67
-rw-r--r--include/linux/of_device.h6
-rw-r--r--include/linux/of_platform.h21
16 files changed, 102 insertions, 103 deletions
diff --git a/arch/microblaze/kernel/of_platform.c b/arch/microblaze/kernel/of_platform.c
index da79edf45420..fb2866104331 100644
--- a/arch/microblaze/kernel/of_platform.c
+++ b/arch/microblaze/kernel/of_platform.c
@@ -26,17 +26,6 @@
26#include <linux/topology.h> 26#include <linux/topology.h>
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28 28
29struct bus_type of_platform_bus_type = {
30 .uevent = of_device_uevent,
31};
32EXPORT_SYMBOL(of_platform_bus_type);
33
34static int __init of_bus_driver_init(void)
35{
36 return of_bus_type_init(&of_platform_bus_type, "of_platform");
37}
38postcore_initcall(of_bus_driver_init);
39
40/* 29/*
41 * The list of OF IDs below is used for matching bus types in the 30 * The list of OF IDs below is used for matching bus types in the
42 * system whose devices are to be exposed as of_platform_devices. 31 * system whose devices are to be exposed as of_platform_devices.
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 17c98dbcec88..f5f768842354 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -213,15 +213,9 @@ static struct notifier_block dflt_plat_bus_notifier = {
213 .priority = INT_MAX, 213 .priority = INT_MAX,
214}; 214};
215 215
216static struct notifier_block dflt_of_bus_notifier = {
217 .notifier_call = dflt_bus_notify,
218 .priority = INT_MAX,
219};
220
221static int __init setup_bus_notifier(void) 216static int __init setup_bus_notifier(void)
222{ 217{
223 bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier); 218 bus_register_notifier(&platform_bus_type, &dflt_plat_bus_notifier);
224 bus_register_notifier(&of_platform_bus_type, &dflt_of_bus_notifier);
225 219
226 return 0; 220 return 0;
227} 221}
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 02f724f36753..4295e0b94b2d 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -82,17 +82,9 @@ static struct notifier_block ppc_swiotlb_plat_bus_notifier = {
82 .priority = 0, 82 .priority = 0,
83}; 83};
84 84
85static struct notifier_block ppc_swiotlb_of_bus_notifier = {
86 .notifier_call = ppc_swiotlb_bus_notify,
87 .priority = 0,
88};
89
90int __init swiotlb_setup_bus_notifier(void) 85int __init swiotlb_setup_bus_notifier(void)
91{ 86{
92 bus_register_notifier(&platform_bus_type, 87 bus_register_notifier(&platform_bus_type,
93 &ppc_swiotlb_plat_bus_notifier); 88 &ppc_swiotlb_plat_bus_notifier);
94 bus_register_notifier(&of_platform_bus_type,
95 &ppc_swiotlb_of_bus_notifier);
96
97 return 0; 89 return 0;
98} 90}
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 4e0a2f7c1dd3..d3497cd81e8a 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -52,18 +52,6 @@ const struct of_device_id of_default_bus_ids[] = {
52 {}, 52 {},
53}; 53};
54 54
55struct bus_type of_platform_bus_type = {
56 .uevent = of_device_uevent,
57};
58EXPORT_SYMBOL(of_platform_bus_type);
59
60static int __init of_bus_driver_init(void)
61{
62 return of_bus_type_init(&of_platform_bus_type, "of_platform");
63}
64
65postcore_initcall(of_bus_driver_init);
66
67static int of_dev_node_match(struct device *dev, void *data) 55static int of_dev_node_match(struct device *dev, void *data)
68{ 56{
69 return to_of_device(dev)->dev.of_node == data; 57 return to_of_device(dev)->dev.of_node == data;
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index b7e6c7e193ae..d1a5304b3ddd 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -701,16 +701,9 @@ static struct notifier_block ppc_dflt_plat_bus_notifier = {
701 .priority = INT_MAX, 701 .priority = INT_MAX,
702}; 702};
703 703
704static struct notifier_block ppc_dflt_of_bus_notifier = {
705 .notifier_call = ppc_dflt_bus_notify,
706 .priority = INT_MAX,
707};
708
709static int __init setup_bus_notifier(void) 704static int __init setup_bus_notifier(void)
710{ 705{
711 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier); 706 bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier);
712 bus_register_notifier(&of_platform_bus_type, &ppc_dflt_of_bus_notifier);
713
714 return 0; 707 return 0;
715} 708}
716 709
diff --git a/arch/powerpc/platforms/cell/beat_iommu.c b/arch/powerpc/platforms/cell/beat_iommu.c
index 39d361c5c6d2..beec405eb6f8 100644
--- a/arch/powerpc/platforms/cell/beat_iommu.c
+++ b/arch/powerpc/platforms/cell/beat_iommu.c
@@ -108,7 +108,7 @@ static int __init celleb_init_iommu(void)
108 celleb_init_direct_mapping(); 108 celleb_init_direct_mapping();
109 set_pci_dma_ops(&dma_direct_ops); 109 set_pci_dma_ops(&dma_direct_ops);
110 ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup; 110 ppc_md.pci_dma_dev_setup = celleb_pci_dma_dev_setup;
111 bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier); 111 bus_register_notifier(&platform_bus_type, &celleb_of_bus_notifier);
112 112
113 return 0; 113 return 0;
114} 114}
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 3712900471ba..58b13ce3847e 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -1204,7 +1204,7 @@ static int __init cell_iommu_init(void)
1204 /* Register callbacks on OF platform device addition/removal 1204 /* Register callbacks on OF platform device addition/removal
1205 * to handle linking them to the right DMA operations 1205 * to handle linking them to the right DMA operations
1206 */ 1206 */
1207 bus_register_notifier(&of_platform_bus_type, &cell_of_bus_notifier); 1207 bus_register_notifier(&platform_bus_type, &cell_of_bus_notifier);
1208 1208
1209 return 0; 1209 return 0;
1210} 1210}
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 31acd3b1718b..1398bc454999 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -20,12 +20,7 @@
20 20
21#include <asm/prom.h> 21#include <asm/prom.h>
22 22
23/* 23/* These functions provide the necessary setup for the mv64x60 drivers. */
24 * These functions provide the necessary setup for the mv64x60 drivers.
25 * These drivers are unusual in that they work on both the MIPS and PowerPC
26 * architectures. Because of that, the drivers do not support the normal
27 * PowerPC of_platform_bus_type. They support platform_bus_type instead.
28 */
29 24
30static struct of_device_id __initdata of_mv64x60_devices[] = { 25static struct of_device_id __initdata of_mv64x60_devices[] = {
31 { .compatible = "marvell,mv64306-devctrl", }, 26 { .compatible = "marvell,mv64306-devctrl", },
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 331de91ad2bc..75fc9d5cd7e6 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -424,7 +424,7 @@ build_resources:
424 build_device_resources(op, parent); 424 build_device_resources(op, parent);
425 425
426 op->dev.parent = parent; 426 op->dev.parent = parent;
427 op->dev.bus = &of_platform_bus_type; 427 op->dev.bus = &platform_bus_type;
428 if (!parent) 428 if (!parent)
429 dev_set_name(&op->dev, "root"); 429 dev_set_name(&op->dev, "root");
430 else 430 else
@@ -452,30 +452,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent)
452 } 452 }
453} 453}
454 454
455static void __init scan_of_devices(void) 455static int __init scan_of_devices(void)
456{ 456{
457 struct device_node *root = of_find_node_by_path("/"); 457 struct device_node *root = of_find_node_by_path("/");
458 struct of_device *parent; 458 struct of_device *parent;
459 459
460 parent = scan_one_device(root, NULL); 460 parent = scan_one_device(root, NULL);
461 if (!parent) 461 if (!parent)
462 return; 462 return 0;
463 463
464 scan_tree(root->child, &parent->dev); 464 scan_tree(root->child, &parent->dev);
465 return 0;
465} 466}
466 467postcore_initcall(scan_of_devices);
467static int __init of_bus_driver_init(void)
468{
469 int err;
470
471 err = of_bus_type_init(&of_platform_bus_type, "of");
472 if (!err)
473 scan_of_devices();
474
475 return err;
476}
477
478postcore_initcall(of_bus_driver_init);
479 468
480static int __init of_debug(char *str) 469static int __init of_debug(char *str)
481{ 470{
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 5e8cbb942d3d..9743d1d9fa03 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -667,7 +667,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
667 op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]); 667 op->archdata.irqs[i] = build_one_device_irq(op, parent, op->archdata.irqs[i]);
668 668
669 op->dev.parent = parent; 669 op->dev.parent = parent;
670 op->dev.bus = &of_platform_bus_type; 670 op->dev.bus = &platform_bus_type;
671 if (!parent) 671 if (!parent)
672 dev_set_name(&op->dev, "root"); 672 dev_set_name(&op->dev, "root");
673 else 673 else
@@ -695,30 +695,19 @@ static void __init scan_tree(struct device_node *dp, struct device *parent)
695 } 695 }
696} 696}
697 697
698static void __init scan_of_devices(void) 698static int __init scan_of_devices(void)
699{ 699{
700 struct device_node *root = of_find_node_by_path("/"); 700 struct device_node *root = of_find_node_by_path("/");
701 struct of_device *parent; 701 struct of_device *parent;
702 702
703 parent = scan_one_device(root, NULL); 703 parent = scan_one_device(root, NULL);
704 if (!parent) 704 if (!parent)
705 return; 705 return 0;
706 706
707 scan_tree(root->child, &parent->dev); 707 scan_tree(root->child, &parent->dev);
708 return 0;
708} 709}
709 710postcore_initcall(scan_of_devices);
710static int __init of_bus_driver_init(void)
711{
712 int err;
713
714 err = of_bus_type_init(&of_platform_bus_type, "of");
715 if (!err)
716 scan_of_devices();
717
718 return err;
719}
720
721postcore_initcall(of_bus_driver_init);
722 711
723static int __init of_debug(char *str) 712static int __init of_debug(char *str)
724{ 713{
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c
index 016c947d4cae..01f380c7995c 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -64,9 +64,6 @@ void of_propagate_archdata(struct of_device *bus)
64 } 64 }
65} 65}
66 66
67struct bus_type of_platform_bus_type;
68EXPORT_SYMBOL(of_platform_bus_type);
69
70static void get_cells(struct device_node *dp, int *addrc, int *sizec) 67static void get_cells(struct device_node *dp, int *addrc, int *sizec)
71{ 68{
72 if (addrc) 69 if (addrc)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index fac3633c7223..f699fabf403b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -636,6 +636,12 @@ static struct device_attribute platform_dev_attrs[] = {
636static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) 636static int platform_uevent(struct device *dev, struct kobj_uevent_env *env)
637{ 637{
638 struct platform_device *pdev = to_platform_device(dev); 638 struct platform_device *pdev = to_platform_device(dev);
639 int rc;
640
641 /* Some devices have extra OF data and an OF-style MODALIAS */
642 rc = of_device_uevent(dev,env);
643 if (rc != -ENODEV)
644 return rc;
639 645
640 add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, 646 add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX,
641 (pdev->id_entry) ? pdev->id_entry->name : pdev->name); 647 (pdev->id_entry) ? pdev->id_entry->name : pdev->name);
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 5282a202f5a9..12a44b493511 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -104,6 +104,11 @@ int of_device_register(struct of_device *ofdev)
104 104
105 device_initialize(&ofdev->dev); 105 device_initialize(&ofdev->dev);
106 106
107 /* name and id have to be set so that the platform bus doesn't get
108 * confused on matching */
109 ofdev->name = dev_name(&ofdev->dev);
110 ofdev->id = -1;
111
107 /* device_add will assume that this device is on the same node as 112 /* device_add will assume that this device is on the same node as
108 * the parent. If there is no parent defined, set the node 113 * the parent. If there is no parent defined, set the node
109 * explicitly */ 114 * explicitly */
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 9d3d932bcb6f..712dfd866df0 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -20,6 +20,54 @@
20#include <linux/of_device.h> 20#include <linux/of_device.h>
21#include <linux/of_irq.h> 21#include <linux/of_irq.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/platform_device.h>
24
25static int platform_driver_probe_shim(struct platform_device *pdev)
26{
27 struct platform_driver *pdrv;
28 struct of_platform_driver *ofpdrv;
29 const struct of_device_id *match;
30
31 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
32 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
33 match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
34 return ofpdrv->probe(pdev, match);
35}
36
37static void platform_driver_shutdown_shim(struct platform_device *pdev)
38{
39 struct platform_driver *pdrv;
40 struct of_platform_driver *ofpdrv;
41
42 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
43 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
44 ofpdrv->shutdown(pdev);
45}
46
47/**
48 * of_register_platform_driver
49 */
50int of_register_platform_driver(struct of_platform_driver *drv)
51{
52 /* setup of_platform_driver to platform_driver adaptors */
53 drv->platform_driver.driver = drv->driver;
54 if (drv->probe)
55 drv->platform_driver.probe = platform_driver_probe_shim;
56 drv->platform_driver.remove = drv->remove;
57 if (drv->shutdown)
58 drv->platform_driver.shutdown = platform_driver_shutdown_shim;
59 drv->platform_driver.suspend = drv->suspend;
60 drv->platform_driver.resume = drv->resume;
61
62 return platform_driver_register(&drv->platform_driver);
63}
64EXPORT_SYMBOL(of_register_platform_driver);
65
66void of_unregister_platform_driver(struct of_platform_driver *drv)
67{
68 platform_driver_unregister(&drv->platform_driver);
69}
70EXPORT_SYMBOL(of_unregister_platform_driver);
23 71
24#if defined(CONFIG_PPC_DCR) 72#if defined(CONFIG_PPC_DCR)
25#include <asm/dcr.h> 73#include <asm/dcr.h>
@@ -392,16 +440,29 @@ int of_bus_type_init(struct bus_type *bus, const char *name)
392 440
393int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus) 441int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus)
394{ 442{
395 drv->driver.bus = bus; 443 /*
444 * Temporary: of_platform_bus used to be distinct from the platform
445 * bus. It isn't anymore, and so drivers on the platform bus need
446 * to be registered in a special way.
447 *
448 * After all of_platform_bus_type drivers are converted to
449 * platform_drivers, this exception can be removed.
450 */
451 if (bus == &platform_bus_type)
452 return of_register_platform_driver(drv);
396 453
397 /* register with core */ 454 /* register with core */
455 drv->driver.bus = bus;
398 return driver_register(&drv->driver); 456 return driver_register(&drv->driver);
399} 457}
400EXPORT_SYMBOL(of_register_driver); 458EXPORT_SYMBOL(of_register_driver);
401 459
402void of_unregister_driver(struct of_platform_driver *drv) 460void of_unregister_driver(struct of_platform_driver *drv)
403{ 461{
404 driver_unregister(&drv->driver); 462 if (drv->driver.bus == &platform_bus_type)
463 of_unregister_platform_driver(drv);
464 else
465 driver_unregister(&drv->driver);
405} 466}
406EXPORT_SYMBOL(of_unregister_driver); 467EXPORT_SYMBOL(of_unregister_driver);
407 468
@@ -548,7 +609,7 @@ struct of_device *of_platform_device_create(struct device_node *np,
548 dev->archdata.dma_mask = 0xffffffffUL; 609 dev->archdata.dma_mask = 0xffffffffUL;
549#endif 610#endif
550 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 611 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
551 dev->dev.bus = &of_platform_bus_type; 612 dev->dev.bus = &platform_bus_type;
552 613
553 /* We do not fill the DMA ops for platform devices by default. 614 /* We do not fill the DMA ops for platform devices by default.
554 * This is currently the responsibility of the platform code 615 * This is currently the responsibility of the platform code
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 7d27f5a878f6..8cd1fe7864e3 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -65,6 +65,12 @@ static inline int of_driver_match_device(struct device *dev,
65 return 0; 65 return 0;
66} 66}
67 67
68static inline int of_device_uevent(struct device *dev,
69 struct kobj_uevent_env *env)
70{
71 return -ENODEV;
72}
73
68#endif /* CONFIG_OF_DEVICE */ 74#endif /* CONFIG_OF_DEVICE */
69 75
70#endif /* _LINUX_OF_DEVICE_H */ 76#endif /* _LINUX_OF_DEVICE_H */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index a51fd30176aa..133ecf31a60f 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -17,19 +17,19 @@
17#include <linux/mod_devicetable.h> 17#include <linux/mod_devicetable.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/of_device.h> 19#include <linux/of_device.h>
20#include <linux/platform_device.h>
20 21
21/* 22/*
22 * The of_platform_bus_type is a bus type used by drivers that do not 23 * of_platform_bus_type isn't it's own bus anymore. It's now just an alias
23 * attach to a macio or similar bus but still use OF probing 24 * for the platform bus.
24 * mechanism
25 */ 25 */
26extern struct bus_type of_platform_bus_type; 26#define of_platform_bus_type platform_bus_type
27 27
28extern const struct of_device_id of_default_bus_ids[]; 28extern const struct of_device_id of_default_bus_ids[];
29 29
30/* 30/*
31 * An of_platform_driver driver is attached to a basic of_device on 31 * An of_platform_driver driver is attached to a basic of_device on
32 * the "platform bus" (of_platform_bus_type). 32 * the "platform bus" (platform_bus_type).
33 */ 33 */
34struct of_platform_driver 34struct of_platform_driver
35{ 35{
@@ -42,6 +42,7 @@ struct of_platform_driver
42 int (*shutdown)(struct of_device* dev); 42 int (*shutdown)(struct of_device* dev);
43 43
44 struct device_driver driver; 44 struct device_driver driver;
45 struct platform_driver platform_driver;
45}; 46};
46#define to_of_platform_driver(drv) \ 47#define to_of_platform_driver(drv) \
47 container_of(drv,struct of_platform_driver, driver) 48 container_of(drv,struct of_platform_driver, driver)
@@ -51,14 +52,8 @@ extern int of_register_driver(struct of_platform_driver *drv,
51extern void of_unregister_driver(struct of_platform_driver *drv); 52extern void of_unregister_driver(struct of_platform_driver *drv);
52 53
53/* Platform drivers register/unregister */ 54/* Platform drivers register/unregister */
54static inline int of_register_platform_driver(struct of_platform_driver *drv) 55extern int of_register_platform_driver(struct of_platform_driver *drv);
55{ 56extern void of_unregister_platform_driver(struct of_platform_driver *drv);
56 return of_register_driver(drv, &of_platform_bus_type);
57}
58static inline void of_unregister_platform_driver(struct of_platform_driver *drv)
59{
60 of_unregister_driver(drv);
61}
62 57
63extern struct of_device *of_device_alloc(struct device_node *np, 58extern struct of_device *of_device_alloc(struct device_node *np,
64 const char *bus_id, 59 const char *bus_id,