diff options
Diffstat (limited to 'arch/sparc/kernel/of_device.c')
-rw-r--r-- | arch/sparc/kernel/of_device.c | 107 |
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 | |||
12 | static 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 | |||
24 | static 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 | |||
48 | static 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 | |||
58 | static 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 | |||
69 | static 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 | ||
80 | static int node_match(struct device *dev, void *data) | 12 | static 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) | |||
98 | EXPORT_SYMBOL(of_find_device_by_node); | 30 | EXPORT_SYMBOL(of_find_device_by_node); |
99 | 31 | ||
100 | #ifdef CONFIG_PCI | 32 | #ifdef CONFIG_PCI |
101 | struct bus_type ebus_bus_type = { | 33 | struct 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 | }; | ||
109 | EXPORT_SYMBOL(ebus_bus_type); | 34 | EXPORT_SYMBOL(ebus_bus_type); |
110 | #endif | 35 | #endif |
111 | 36 | ||
112 | #ifdef CONFIG_SBUS | 37 | #ifdef CONFIG_SBUS |
113 | struct bus_type sbus_bus_type = { | 38 | struct 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 | }; | ||
121 | EXPORT_SYMBOL(sbus_bus_type); | 39 | EXPORT_SYMBOL(sbus_bus_type); |
122 | #endif | 40 | #endif |
123 | 41 | ||
124 | struct bus_type of_platform_bus_type = { | 42 | struct 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 | }; | ||
132 | EXPORT_SYMBOL(of_platform_bus_type); | 43 | EXPORT_SYMBOL(of_platform_bus_type); |
133 | 44 | ||
134 | static inline u64 of_read_addr(const u32 *cell, int size) | 45 | static 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) |