aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-02-17 02:26:57 -0500
committerGrant Likely <grant.likely@secretlab.ca>2011-02-28 03:36:38 -0500
commit710ac54be44e0cc53f5bf29b03d12c8706e7077a (patch)
tree82b570917ae685b981f55df85f0eff48576db7cc /drivers
parentb826291c14c396e7aa5d84523aafac117f430902 (diff)
dt/powerpc: move of_bus_type infrastructure to ibmebus
arch/powerpc/kernel/ibmebus.c is the only remaining user of the of_bus_type support code for initializing the bus and registering drivers. All others have either been switched to the vanilla platform bus or already have their own infrastructure. This patch moves the functionality that ibmebus is using out of drivers/of/{platform,device}.c and into ibmebus.c where it is actually used. Also renames the moved symbols from of_platform_* to ibmebus_bus_* to reflect the actual usage. This patch is part of moving all of the of_platform_bus_type users over to the platform_bus_type. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/device.c34
-rw-r--r--drivers/of/platform.c393
2 files changed, 0 insertions, 427 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 45d86530799f..62b4b32ac887 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -47,40 +47,6 @@ void of_dev_put(struct platform_device *dev)
47} 47}
48EXPORT_SYMBOL(of_dev_put); 48EXPORT_SYMBOL(of_dev_put);
49 49
50static ssize_t devspec_show(struct device *dev,
51 struct device_attribute *attr, char *buf)
52{
53 struct platform_device *ofdev;
54
55 ofdev = to_platform_device(dev);
56 return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
57}
58
59static ssize_t name_show(struct device *dev,
60 struct device_attribute *attr, char *buf)
61{
62 struct platform_device *ofdev;
63
64 ofdev = to_platform_device(dev);
65 return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
66}
67
68static ssize_t modalias_show(struct device *dev,
69 struct device_attribute *attr, char *buf)
70{
71 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
72 buf[len] = '\n';
73 buf[len+1] = 0;
74 return len+1;
75}
76
77struct device_attribute of_platform_device_attrs[] = {
78 __ATTR_RO(devspec),
79 __ATTR_RO(name),
80 __ATTR_RO(modalias),
81 __ATTR_NULL
82};
83
84int of_device_add(struct platform_device *ofdev) 50int of_device_add(struct platform_device *ofdev)
85{ 51{
86 BUG_ON(ofdev->dev.of_node == NULL); 52 BUG_ON(ofdev->dev.of_node == NULL);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index c01cd1ac7617..b71d0cdc4209 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -114,399 +114,6 @@ EXPORT_SYMBOL(of_unregister_platform_driver);
114#include <asm/dcr.h> 114#include <asm/dcr.h>
115#endif 115#endif
116 116
117extern struct device_attribute of_platform_device_attrs[];
118
119static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
120{
121 const struct of_device_id *matches = drv->of_match_table;
122
123 if (!matches)
124 return 0;
125
126 return of_match_device(matches, dev) != NULL;
127}
128
129static int of_platform_device_probe(struct device *dev)
130{
131 int error = -ENODEV;
132 struct of_platform_driver *drv;
133 struct platform_device *of_dev;
134 const struct of_device_id *match;
135
136 drv = to_of_platform_driver(dev->driver);
137 of_dev = to_platform_device(dev);
138
139 if (!drv->probe)
140 return error;
141
142 of_dev_get(of_dev);
143
144 match = of_match_device(drv->driver.of_match_table, dev);
145 if (match)
146 error = drv->probe(of_dev, match);
147 if (error)
148 of_dev_put(of_dev);
149
150 return error;
151}
152
153static int of_platform_device_remove(struct device *dev)
154{
155 struct platform_device *of_dev = to_platform_device(dev);
156 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
157
158 if (dev->driver && drv->remove)
159 drv->remove(of_dev);
160 return 0;
161}
162
163static void of_platform_device_shutdown(struct device *dev)
164{
165 struct platform_device *of_dev = to_platform_device(dev);
166 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
167
168 if (dev->driver && drv->shutdown)
169 drv->shutdown(of_dev);
170}
171
172#ifdef CONFIG_PM_SLEEP
173
174static int of_platform_legacy_suspend(struct device *dev, pm_message_t mesg)
175{
176 struct platform_device *of_dev = to_platform_device(dev);
177 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
178 int ret = 0;
179
180 if (dev->driver && drv->suspend)
181 ret = drv->suspend(of_dev, mesg);
182 return ret;
183}
184
185static int of_platform_legacy_resume(struct device *dev)
186{
187 struct platform_device *of_dev = to_platform_device(dev);
188 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
189 int ret = 0;
190
191 if (dev->driver && drv->resume)
192 ret = drv->resume(of_dev);
193 return ret;
194}
195
196static int of_platform_pm_prepare(struct device *dev)
197{
198 struct device_driver *drv = dev->driver;
199 int ret = 0;
200
201 if (drv && drv->pm && drv->pm->prepare)
202 ret = drv->pm->prepare(dev);
203
204 return ret;
205}
206
207static void of_platform_pm_complete(struct device *dev)
208{
209 struct device_driver *drv = dev->driver;
210
211 if (drv && drv->pm && drv->pm->complete)
212 drv->pm->complete(dev);
213}
214
215#ifdef CONFIG_SUSPEND
216
217static int of_platform_pm_suspend(struct device *dev)
218{
219 struct device_driver *drv = dev->driver;
220 int ret = 0;
221
222 if (!drv)
223 return 0;
224
225 if (drv->pm) {
226 if (drv->pm->suspend)
227 ret = drv->pm->suspend(dev);
228 } else {
229 ret = of_platform_legacy_suspend(dev, PMSG_SUSPEND);
230 }
231
232 return ret;
233}
234
235static int of_platform_pm_suspend_noirq(struct device *dev)
236{
237 struct device_driver *drv = dev->driver;
238 int ret = 0;
239
240 if (!drv)
241 return 0;
242
243 if (drv->pm) {
244 if (drv->pm->suspend_noirq)
245 ret = drv->pm->suspend_noirq(dev);
246 }
247
248 return ret;
249}
250
251static int of_platform_pm_resume(struct device *dev)
252{
253 struct device_driver *drv = dev->driver;
254 int ret = 0;
255
256 if (!drv)
257 return 0;
258
259 if (drv->pm) {
260 if (drv->pm->resume)
261 ret = drv->pm->resume(dev);
262 } else {
263 ret = of_platform_legacy_resume(dev);
264 }
265
266 return ret;
267}
268
269static int of_platform_pm_resume_noirq(struct device *dev)
270{
271 struct device_driver *drv = dev->driver;
272 int ret = 0;
273
274 if (!drv)
275 return 0;
276
277 if (drv->pm) {
278 if (drv->pm->resume_noirq)
279 ret = drv->pm->resume_noirq(dev);
280 }
281
282 return ret;
283}
284
285#else /* !CONFIG_SUSPEND */
286
287#define of_platform_pm_suspend NULL
288#define of_platform_pm_resume NULL
289#define of_platform_pm_suspend_noirq NULL
290#define of_platform_pm_resume_noirq NULL
291
292#endif /* !CONFIG_SUSPEND */
293
294#ifdef CONFIG_HIBERNATION
295
296static int of_platform_pm_freeze(struct device *dev)
297{
298 struct device_driver *drv = dev->driver;
299 int ret = 0;
300
301 if (!drv)
302 return 0;
303
304 if (drv->pm) {
305 if (drv->pm->freeze)
306 ret = drv->pm->freeze(dev);
307 } else {
308 ret = of_platform_legacy_suspend(dev, PMSG_FREEZE);
309 }
310
311 return ret;
312}
313
314static int of_platform_pm_freeze_noirq(struct device *dev)
315{
316 struct device_driver *drv = dev->driver;
317 int ret = 0;
318
319 if (!drv)
320 return 0;
321
322 if (drv->pm) {
323 if (drv->pm->freeze_noirq)
324 ret = drv->pm->freeze_noirq(dev);
325 }
326
327 return ret;
328}
329
330static int of_platform_pm_thaw(struct device *dev)
331{
332 struct device_driver *drv = dev->driver;
333 int ret = 0;
334
335 if (!drv)
336 return 0;
337
338 if (drv->pm) {
339 if (drv->pm->thaw)
340 ret = drv->pm->thaw(dev);
341 } else {
342 ret = of_platform_legacy_resume(dev);
343 }
344
345 return ret;
346}
347
348static int of_platform_pm_thaw_noirq(struct device *dev)
349{
350 struct device_driver *drv = dev->driver;
351 int ret = 0;
352
353 if (!drv)
354 return 0;
355
356 if (drv->pm) {
357 if (drv->pm->thaw_noirq)
358 ret = drv->pm->thaw_noirq(dev);
359 }
360
361 return ret;
362}
363
364static int of_platform_pm_poweroff(struct device *dev)
365{
366 struct device_driver *drv = dev->driver;
367 int ret = 0;
368
369 if (!drv)
370 return 0;
371
372 if (drv->pm) {
373 if (drv->pm->poweroff)
374 ret = drv->pm->poweroff(dev);
375 } else {
376 ret = of_platform_legacy_suspend(dev, PMSG_HIBERNATE);
377 }
378
379 return ret;
380}
381
382static int of_platform_pm_poweroff_noirq(struct device *dev)
383{
384 struct device_driver *drv = dev->driver;
385 int ret = 0;
386
387 if (!drv)
388 return 0;
389
390 if (drv->pm) {
391 if (drv->pm->poweroff_noirq)
392 ret = drv->pm->poweroff_noirq(dev);
393 }
394
395 return ret;
396}
397
398static int of_platform_pm_restore(struct device *dev)
399{
400 struct device_driver *drv = dev->driver;
401 int ret = 0;
402
403 if (!drv)
404 return 0;
405
406 if (drv->pm) {
407 if (drv->pm->restore)
408 ret = drv->pm->restore(dev);
409 } else {
410 ret = of_platform_legacy_resume(dev);
411 }
412
413 return ret;
414}
415
416static int of_platform_pm_restore_noirq(struct device *dev)
417{
418 struct device_driver *drv = dev->driver;
419 int ret = 0;
420
421 if (!drv)
422 return 0;
423
424 if (drv->pm) {
425 if (drv->pm->restore_noirq)
426 ret = drv->pm->restore_noirq(dev);
427 }
428
429 return ret;
430}
431
432#else /* !CONFIG_HIBERNATION */
433
434#define of_platform_pm_freeze NULL
435#define of_platform_pm_thaw NULL
436#define of_platform_pm_poweroff NULL
437#define of_platform_pm_restore NULL
438#define of_platform_pm_freeze_noirq NULL
439#define of_platform_pm_thaw_noirq NULL
440#define of_platform_pm_poweroff_noirq NULL
441#define of_platform_pm_restore_noirq NULL
442
443#endif /* !CONFIG_HIBERNATION */
444
445static struct dev_pm_ops of_platform_dev_pm_ops = {
446 .prepare = of_platform_pm_prepare,
447 .complete = of_platform_pm_complete,
448 .suspend = of_platform_pm_suspend,
449 .resume = of_platform_pm_resume,
450 .freeze = of_platform_pm_freeze,
451 .thaw = of_platform_pm_thaw,
452 .poweroff = of_platform_pm_poweroff,
453 .restore = of_platform_pm_restore,
454 .suspend_noirq = of_platform_pm_suspend_noirq,
455 .resume_noirq = of_platform_pm_resume_noirq,
456 .freeze_noirq = of_platform_pm_freeze_noirq,
457 .thaw_noirq = of_platform_pm_thaw_noirq,
458 .poweroff_noirq = of_platform_pm_poweroff_noirq,
459 .restore_noirq = of_platform_pm_restore_noirq,
460};
461
462#define OF_PLATFORM_PM_OPS_PTR (&of_platform_dev_pm_ops)
463
464#else /* !CONFIG_PM_SLEEP */
465
466#define OF_PLATFORM_PM_OPS_PTR NULL
467
468#endif /* !CONFIG_PM_SLEEP */
469
470int of_bus_type_init(struct bus_type *bus, const char *name)
471{
472 bus->name = name;
473 bus->match = of_platform_bus_match;
474 bus->probe = of_platform_device_probe;
475 bus->remove = of_platform_device_remove;
476 bus->shutdown = of_platform_device_shutdown;
477 bus->dev_attrs = of_platform_device_attrs;
478 bus->pm = OF_PLATFORM_PM_OPS_PTR;
479 return bus_register(bus);
480}
481
482int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus)
483{
484 /*
485 * Temporary: of_platform_bus used to be distinct from the platform
486 * bus. It isn't anymore, and so drivers on the platform bus need
487 * to be registered in a special way.
488 *
489 * After all of_platform_bus_type drivers are converted to
490 * platform_drivers, this exception can be removed.
491 */
492 if (bus == &platform_bus_type)
493 return of_register_platform_driver(drv);
494
495 /* register with core */
496 drv->driver.bus = bus;
497 return driver_register(&drv->driver);
498}
499EXPORT_SYMBOL(of_register_driver);
500
501void of_unregister_driver(struct of_platform_driver *drv)
502{
503 if (drv->driver.bus == &platform_bus_type)
504 of_unregister_platform_driver(drv);
505 else
506 driver_unregister(&drv->driver);
507}
508EXPORT_SYMBOL(of_unregister_driver);
509
510#if !defined(CONFIG_SPARC) 117#if !defined(CONFIG_SPARC)
511/* 118/*
512 * The following routines scan a subtree and registers a device for 119 * The following routines scan a subtree and registers a device for