aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/ibmebus.c404
-rw-r--r--drivers/of/device.c34
-rw-r--r--drivers/of/platform.c393
-rw-r--r--include/linux/of_platform.h6
4 files changed, 400 insertions, 437 deletions
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index f62efdfd1769..c00d4ca1ee15 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -201,13 +201,14 @@ int ibmebus_register_driver(struct of_platform_driver *drv)
201 /* If the driver uses devices that ibmebus doesn't know, add them */ 201 /* If the driver uses devices that ibmebus doesn't know, add them */
202 ibmebus_create_devices(drv->driver.of_match_table); 202 ibmebus_create_devices(drv->driver.of_match_table);
203 203
204 return of_register_driver(drv, &ibmebus_bus_type); 204 drv->driver.bus = &ibmebus_bus_type;
205 return driver_register(&drv->driver);
205} 206}
206EXPORT_SYMBOL(ibmebus_register_driver); 207EXPORT_SYMBOL(ibmebus_register_driver);
207 208
208void ibmebus_unregister_driver(struct of_platform_driver *drv) 209void ibmebus_unregister_driver(struct of_platform_driver *drv)
209{ 210{
210 of_unregister_driver(drv); 211 driver_unregister(&drv->driver);
211} 212}
212EXPORT_SYMBOL(ibmebus_unregister_driver); 213EXPORT_SYMBOL(ibmebus_unregister_driver);
213 214
@@ -308,15 +309,410 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
308 } 309 }
309} 310}
310 311
312
311static struct bus_attribute ibmebus_bus_attrs[] = { 313static struct bus_attribute ibmebus_bus_attrs[] = {
312 __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe), 314 __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
313 __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove), 315 __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
314 __ATTR_NULL 316 __ATTR_NULL
315}; 317};
316 318
319static int ibmebus_bus_bus_match(struct device *dev, struct device_driver *drv)
320{
321 const struct of_device_id *matches = drv->of_match_table;
322
323 if (!matches)
324 return 0;
325
326 return of_match_device(matches, dev) != NULL;
327}
328
329static int ibmebus_bus_device_probe(struct device *dev)
330{
331 int error = -ENODEV;
332 struct of_platform_driver *drv;
333 struct platform_device *of_dev;
334 const struct of_device_id *match;
335
336 drv = to_of_platform_driver(dev->driver);
337 of_dev = to_platform_device(dev);
338
339 if (!drv->probe)
340 return error;
341
342 of_dev_get(of_dev);
343
344 match = of_match_device(drv->driver.of_match_table, dev);
345 if (match)
346 error = drv->probe(of_dev, match);
347 if (error)
348 of_dev_put(of_dev);
349
350 return error;
351}
352
353static int ibmebus_bus_device_remove(struct device *dev)
354{
355 struct platform_device *of_dev = to_platform_device(dev);
356 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
357
358 if (dev->driver && drv->remove)
359 drv->remove(of_dev);
360 return 0;
361}
362
363static void ibmebus_bus_device_shutdown(struct device *dev)
364{
365 struct platform_device *of_dev = to_platform_device(dev);
366 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
367
368 if (dev->driver && drv->shutdown)
369 drv->shutdown(of_dev);
370}
371
372/*
373 * ibmebus_bus_device_attrs
374 */
375static ssize_t devspec_show(struct device *dev,
376 struct device_attribute *attr, char *buf)
377{
378 struct platform_device *ofdev;
379
380 ofdev = to_platform_device(dev);
381 return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
382}
383
384static ssize_t name_show(struct device *dev,
385 struct device_attribute *attr, char *buf)
386{
387 struct platform_device *ofdev;
388
389 ofdev = to_platform_device(dev);
390 return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
391}
392
393static ssize_t modalias_show(struct device *dev,
394 struct device_attribute *attr, char *buf)
395{
396 ssize_t len = of_device_get_modalias(dev, buf, PAGE_SIZE - 2);
397 buf[len] = '\n';
398 buf[len+1] = 0;
399 return len+1;
400}
401
402struct device_attribute ibmebus_bus_device_attrs[] = {
403 __ATTR_RO(devspec),
404 __ATTR_RO(name),
405 __ATTR_RO(modalias),
406 __ATTR_NULL
407};
408
409#ifdef CONFIG_PM_SLEEP
410static int ibmebus_bus_legacy_suspend(struct device *dev, pm_message_t mesg)
411{
412 struct platform_device *of_dev = to_platform_device(dev);
413 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
414 int ret = 0;
415
416 if (dev->driver && drv->suspend)
417 ret = drv->suspend(of_dev, mesg);
418 return ret;
419}
420
421static int ibmebus_bus_legacy_resume(struct device *dev)
422{
423 struct platform_device *of_dev = to_platform_device(dev);
424 struct of_platform_driver *drv = to_of_platform_driver(dev->driver);
425 int ret = 0;
426
427 if (dev->driver && drv->resume)
428 ret = drv->resume(of_dev);
429 return ret;
430}
431
432static int ibmebus_bus_pm_prepare(struct device *dev)
433{
434 struct device_driver *drv = dev->driver;
435 int ret = 0;
436
437 if (drv && drv->pm && drv->pm->prepare)
438 ret = drv->pm->prepare(dev);
439
440 return ret;
441}
442
443static void ibmebus_bus_pm_complete(struct device *dev)
444{
445 struct device_driver *drv = dev->driver;
446
447 if (drv && drv->pm && drv->pm->complete)
448 drv->pm->complete(dev);
449}
450
451#ifdef CONFIG_SUSPEND
452
453static int ibmebus_bus_pm_suspend(struct device *dev)
454{
455 struct device_driver *drv = dev->driver;
456 int ret = 0;
457
458 if (!drv)
459 return 0;
460
461 if (drv->pm) {
462 if (drv->pm->suspend)
463 ret = drv->pm->suspend(dev);
464 } else {
465 ret = ibmebus_bus_legacy_suspend(dev, PMSG_SUSPEND);
466 }
467
468 return ret;
469}
470
471static int ibmebus_bus_pm_suspend_noirq(struct device *dev)
472{
473 struct device_driver *drv = dev->driver;
474 int ret = 0;
475
476 if (!drv)
477 return 0;
478
479 if (drv->pm) {
480 if (drv->pm->suspend_noirq)
481 ret = drv->pm->suspend_noirq(dev);
482 }
483
484 return ret;
485}
486
487static int ibmebus_bus_pm_resume(struct device *dev)
488{
489 struct device_driver *drv = dev->driver;
490 int ret = 0;
491
492 if (!drv)
493 return 0;
494
495 if (drv->pm) {
496 if (drv->pm->resume)
497 ret = drv->pm->resume(dev);
498 } else {
499 ret = ibmebus_bus_legacy_resume(dev);
500 }
501
502 return ret;
503}
504
505static int ibmebus_bus_pm_resume_noirq(struct device *dev)
506{
507 struct device_driver *drv = dev->driver;
508 int ret = 0;
509
510 if (!drv)
511 return 0;
512
513 if (drv->pm) {
514 if (drv->pm->resume_noirq)
515 ret = drv->pm->resume_noirq(dev);
516 }
517
518 return ret;
519}
520
521#else /* !CONFIG_SUSPEND */
522
523#define ibmebus_bus_pm_suspend NULL
524#define ibmebus_bus_pm_resume NULL
525#define ibmebus_bus_pm_suspend_noirq NULL
526#define ibmebus_bus_pm_resume_noirq NULL
527
528#endif /* !CONFIG_SUSPEND */
529
530#ifdef CONFIG_HIBERNATION
531
532static int ibmebus_bus_pm_freeze(struct device *dev)
533{
534 struct device_driver *drv = dev->driver;
535 int ret = 0;
536
537 if (!drv)
538 return 0;
539
540 if (drv->pm) {
541 if (drv->pm->freeze)
542 ret = drv->pm->freeze(dev);
543 } else {
544 ret = ibmebus_bus_legacy_suspend(dev, PMSG_FREEZE);
545 }
546
547 return ret;
548}
549
550static int ibmebus_bus_pm_freeze_noirq(struct device *dev)
551{
552 struct device_driver *drv = dev->driver;
553 int ret = 0;
554
555 if (!drv)
556 return 0;
557
558 if (drv->pm) {
559 if (drv->pm->freeze_noirq)
560 ret = drv->pm->freeze_noirq(dev);
561 }
562
563 return ret;
564}
565
566static int ibmebus_bus_pm_thaw(struct device *dev)
567{
568 struct device_driver *drv = dev->driver;
569 int ret = 0;
570
571 if (!drv)
572 return 0;
573
574 if (drv->pm) {
575 if (drv->pm->thaw)
576 ret = drv->pm->thaw(dev);
577 } else {
578 ret = ibmebus_bus_legacy_resume(dev);
579 }
580
581 return ret;
582}
583
584static int ibmebus_bus_pm_thaw_noirq(struct device *dev)
585{
586 struct device_driver *drv = dev->driver;
587 int ret = 0;
588
589 if (!drv)
590 return 0;
591
592 if (drv->pm) {
593 if (drv->pm->thaw_noirq)
594 ret = drv->pm->thaw_noirq(dev);
595 }
596
597 return ret;
598}
599
600static int ibmebus_bus_pm_poweroff(struct device *dev)
601{
602 struct device_driver *drv = dev->driver;
603 int ret = 0;
604
605 if (!drv)
606 return 0;
607
608 if (drv->pm) {
609 if (drv->pm->poweroff)
610 ret = drv->pm->poweroff(dev);
611 } else {
612 ret = ibmebus_bus_legacy_suspend(dev, PMSG_HIBERNATE);
613 }
614
615 return ret;
616}
617
618static int ibmebus_bus_pm_poweroff_noirq(struct device *dev)
619{
620 struct device_driver *drv = dev->driver;
621 int ret = 0;
622
623 if (!drv)
624 return 0;
625
626 if (drv->pm) {
627 if (drv->pm->poweroff_noirq)
628 ret = drv->pm->poweroff_noirq(dev);
629 }
630
631 return ret;
632}
633
634static int ibmebus_bus_pm_restore(struct device *dev)
635{
636 struct device_driver *drv = dev->driver;
637 int ret = 0;
638
639 if (!drv)
640 return 0;
641
642 if (drv->pm) {
643 if (drv->pm->restore)
644 ret = drv->pm->restore(dev);
645 } else {
646 ret = ibmebus_bus_legacy_resume(dev);
647 }
648
649 return ret;
650}
651
652static int ibmebus_bus_pm_restore_noirq(struct device *dev)
653{
654 struct device_driver *drv = dev->driver;
655 int ret = 0;
656
657 if (!drv)
658 return 0;
659
660 if (drv->pm) {
661 if (drv->pm->restore_noirq)
662 ret = drv->pm->restore_noirq(dev);
663 }
664
665 return ret;
666}
667
668#else /* !CONFIG_HIBERNATION */
669
670#define ibmebus_bus_pm_freeze NULL
671#define ibmebus_bus_pm_thaw NULL
672#define ibmebus_bus_pm_poweroff NULL
673#define ibmebus_bus_pm_restore NULL
674#define ibmebus_bus_pm_freeze_noirq NULL
675#define ibmebus_bus_pm_thaw_noirq NULL
676#define ibmebus_bus_pm_poweroff_noirq NULL
677#define ibmebus_bus_pm_restore_noirq NULL
678
679#endif /* !CONFIG_HIBERNATION */
680
681static struct dev_pm_ops ibmebus_bus_dev_pm_ops = {
682 .prepare = ibmebus_bus_pm_prepare,
683 .complete = ibmebus_bus_pm_complete,
684 .suspend = ibmebus_bus_pm_suspend,
685 .resume = ibmebus_bus_pm_resume,
686 .freeze = ibmebus_bus_pm_freeze,
687 .thaw = ibmebus_bus_pm_thaw,
688 .poweroff = ibmebus_bus_pm_poweroff,
689 .restore = ibmebus_bus_pm_restore,
690 .suspend_noirq = ibmebus_bus_pm_suspend_noirq,
691 .resume_noirq = ibmebus_bus_pm_resume_noirq,
692 .freeze_noirq = ibmebus_bus_pm_freeze_noirq,
693 .thaw_noirq = ibmebus_bus_pm_thaw_noirq,
694 .poweroff_noirq = ibmebus_bus_pm_poweroff_noirq,
695 .restore_noirq = ibmebus_bus_pm_restore_noirq,
696};
697
698#define IBMEBUS_BUS_PM_OPS_PTR (&ibmebus_bus_dev_pm_ops)
699
700#else /* !CONFIG_PM_SLEEP */
701
702#define IBMEBUS_BUS_PM_OPS_PTR NULL
703
704#endif /* !CONFIG_PM_SLEEP */
705
317struct bus_type ibmebus_bus_type = { 706struct bus_type ibmebus_bus_type = {
707 .name = "ibmebus",
318 .uevent = of_device_uevent, 708 .uevent = of_device_uevent,
319 .bus_attrs = ibmebus_bus_attrs 709 .bus_attrs = ibmebus_bus_attrs,
710 .match = ibmebus_bus_bus_match,
711 .probe = ibmebus_bus_device_probe,
712 .remove = ibmebus_bus_device_remove,
713 .shutdown = ibmebus_bus_device_shutdown,
714 .dev_attrs = ibmebus_bus_device_attrs,
715 .pm = IBMEBUS_BUS_PM_OPS_PTR,
320}; 716};
321EXPORT_SYMBOL(ibmebus_bus_type); 717EXPORT_SYMBOL(ibmebus_bus_type);
322 718
@@ -326,7 +722,7 @@ static int __init ibmebus_bus_init(void)
326 722
327 printk(KERN_INFO "IBM eBus Device Driver\n"); 723 printk(KERN_INFO "IBM eBus Device Driver\n");
328 724
329 err = of_bus_type_init(&ibmebus_bus_type, "ibmebus"); 725 err = bus_register(&ibmebus_bus_type);
330 if (err) { 726 if (err) {
331 printk(KERN_ERR "%s: failed to register IBM eBus.\n", 727 printk(KERN_ERR "%s: failed to register IBM eBus.\n",
332 __func__); 728 __func__);
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
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index a68716ad38ce..048949fa1d10 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -47,10 +47,6 @@ struct of_platform_driver
47#define to_of_platform_driver(drv) \ 47#define to_of_platform_driver(drv) \
48 container_of(drv,struct of_platform_driver, driver) 48 container_of(drv,struct of_platform_driver, driver)
49 49
50extern int of_register_driver(struct of_platform_driver *drv,
51 struct bus_type *bus);
52extern void of_unregister_driver(struct of_platform_driver *drv);
53
54/* Platform drivers register/unregister */ 50/* Platform drivers register/unregister */
55extern int of_register_platform_driver(struct of_platform_driver *drv); 51extern int of_register_platform_driver(struct of_platform_driver *drv);
56extern void of_unregister_platform_driver(struct of_platform_driver *drv); 52extern void of_unregister_platform_driver(struct of_platform_driver *drv);
@@ -60,8 +56,6 @@ extern struct platform_device *of_device_alloc(struct device_node *np,
60 struct device *parent); 56 struct device *parent);
61extern struct platform_device *of_find_device_by_node(struct device_node *np); 57extern struct platform_device *of_find_device_by_node(struct device_node *np);
62 58
63extern int of_bus_type_init(struct bus_type *bus, const char *name);
64
65#if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */ 59#if !defined(CONFIG_SPARC) /* SPARC has its own device registration method */
66/* Platform devices and busses creation */ 60/* Platform devices and busses creation */
67extern struct platform_device *of_platform_device_create(struct device_node *np, 61extern struct platform_device *of_platform_device_create(struct device_node *np,