aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/of/platform.c')
-rw-r--r--drivers/of/platform.c67
1 files changed, 64 insertions, 3 deletions
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