aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-05-02 12:38:57 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2007-07-20 00:25:51 -0400
commit3f23de10f283819bcdc0d2282e8b5b14c2e96d3b (patch)
tree49c64fc622953e4ffc3af665bdc380fd37079e14 /arch/sparc
parentb41912ca345e6de8ec8469d57cd585881271e2b9 (diff)
Create drivers/of/platform.c
and populate it with the common parts from PowerPC and Sparc[64]. Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Paul Mackerras <paulus@samba.org> Acked-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/kernel/of_device.c107
1 files changed, 9 insertions, 98 deletions
diff --git a/arch/sparc/kernel/of_device.c b/arch/sparc/kernel/of_device.c
index cb21983cff9f..7176040caba0 100644
--- a/arch/sparc/kernel/of_device.c
+++ b/arch/sparc/kernel/of_device.c
@@ -5,77 +5,9 @@
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/mod_devicetable.h> 6#include <linux/mod_devicetable.h>
7#include <linux/slab.h> 7#include <linux/slab.h>
8 8#include <linux/errno.h>
9#include <asm/errno.h> 9#include <linux/of_device.h>
10#include <asm/of_device.h> 10#include <linux/of_platform.h>
11
12static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
13{
14 struct of_device * of_dev = to_of_device(dev);
15 struct of_platform_driver * of_drv = to_of_platform_driver(drv);
16 const struct of_device_id * matches = of_drv->match_table;
17
18 if (!matches)
19 return 0;
20
21 return of_match_device(matches, of_dev) != NULL;
22}
23
24static int of_platform_device_probe(struct device *dev)
25{
26 int error = -ENODEV;
27 struct of_platform_driver *drv;
28 struct of_device *of_dev;
29 const struct of_device_id *match;
30
31 drv = to_of_platform_driver(dev->driver);
32 of_dev = to_of_device(dev);
33
34 if (!drv->probe)
35 return error;
36
37 of_dev_get(of_dev);
38
39 match = of_match_device(drv->match_table, of_dev);
40 if (match)
41 error = drv->probe(of_dev, match);
42 if (error)
43 of_dev_put(of_dev);
44
45 return error;
46}
47
48static int of_platform_device_remove(struct device *dev)
49{
50 struct of_device * of_dev = to_of_device(dev);
51 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
52
53 if (dev->driver && drv->remove)
54 drv->remove(of_dev);
55 return 0;
56}
57
58static int of_platform_device_suspend(struct device *dev, pm_message_t state)
59{
60 struct of_device * of_dev = to_of_device(dev);
61 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
62 int error = 0;
63
64 if (dev->driver && drv->suspend)
65 error = drv->suspend(of_dev, state);
66 return error;
67}
68
69static int of_platform_device_resume(struct device * dev)
70{
71 struct of_device * of_dev = to_of_device(dev);
72 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
73 int error = 0;
74
75 if (dev->driver && drv->resume)
76 error = drv->resume(of_dev);
77 return error;
78}
79 11
80static int node_match(struct device *dev, void *data) 12static int node_match(struct device *dev, void *data)
81{ 13{
@@ -98,37 +30,16 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
98EXPORT_SYMBOL(of_find_device_by_node); 30EXPORT_SYMBOL(of_find_device_by_node);
99 31
100#ifdef CONFIG_PCI 32#ifdef CONFIG_PCI
101struct bus_type ebus_bus_type = { 33struct bus_type ebus_bus_type;
102 .name = "ebus",
103 .match = of_platform_bus_match,
104 .probe = of_platform_device_probe,
105 .remove = of_platform_device_remove,
106 .suspend = of_platform_device_suspend,
107 .resume = of_platform_device_resume,
108};
109EXPORT_SYMBOL(ebus_bus_type); 34EXPORT_SYMBOL(ebus_bus_type);
110#endif 35#endif
111 36
112#ifdef CONFIG_SBUS 37#ifdef CONFIG_SBUS
113struct bus_type sbus_bus_type = { 38struct bus_type sbus_bus_type;
114 .name = "sbus",
115 .match = of_platform_bus_match,
116 .probe = of_platform_device_probe,
117 .remove = of_platform_device_remove,
118 .suspend = of_platform_device_suspend,
119 .resume = of_platform_device_resume,
120};
121EXPORT_SYMBOL(sbus_bus_type); 39EXPORT_SYMBOL(sbus_bus_type);
122#endif 40#endif
123 41
124struct bus_type of_platform_bus_type = { 42struct bus_type of_platform_bus_type;
125 .name = "of",
126 .match = of_platform_bus_match,
127 .probe = of_platform_device_probe,
128 .remove = of_platform_device_remove,
129 .suspend = of_platform_device_suspend,
130 .resume = of_platform_device_resume,
131};
132EXPORT_SYMBOL(of_platform_bus_type); 43EXPORT_SYMBOL(of_platform_bus_type);
133 44
134static inline u64 of_read_addr(const u32 *cell, int size) 45static inline u64 of_read_addr(const u32 *cell, int size)
@@ -639,14 +550,14 @@ static int __init of_bus_driver_init(void)
639{ 550{
640 int err; 551 int err;
641 552
642 err = bus_register(&of_platform_bus_type); 553 err = of_bus_type_init(&of_platform_bus_type, "of");
643#ifdef CONFIG_PCI 554#ifdef CONFIG_PCI
644 if (!err) 555 if (!err)
645 err = bus_register(&ebus_bus_type); 556 err = of_bus_type_init(&ebus_bus_type, "ebus");
646#endif 557#endif
647#ifdef CONFIG_SBUS 558#ifdef CONFIG_SBUS
648 if (!err) 559 if (!err)
649 err = bus_register(&sbus_bus_type); 560 err = of_bus_type_init(&sbus_bus_type, "sbus");
650#endif 561#endif
651 562
652 if (!err) 563 if (!err)