aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/of/platform.c68
-rw-r--r--include/linux/of_platform.h12
2 files changed, 1 insertions, 79 deletions
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b71d0cdc4209..1ce4c45c4ab2 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -42,74 +42,6 @@ struct platform_device *of_find_device_by_node(struct device_node *np)
42} 42}
43EXPORT_SYMBOL(of_find_device_by_node); 43EXPORT_SYMBOL(of_find_device_by_node);
44 44
45static int platform_driver_probe_shim(struct platform_device *pdev)
46{
47 struct platform_driver *pdrv;
48 struct of_platform_driver *ofpdrv;
49 const struct of_device_id *match;
50
51 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
52 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
53
54 /* There is an unlikely chance that an of_platform driver might match
55 * on a non-OF platform device. If so, then of_match_device() will
56 * come up empty. Return -EINVAL in this case so other drivers get
57 * the chance to bind. */
58 match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
59 return match ? ofpdrv->probe(pdev, match) : -EINVAL;
60}
61
62static void platform_driver_shutdown_shim(struct platform_device *pdev)
63{
64 struct platform_driver *pdrv;
65 struct of_platform_driver *ofpdrv;
66
67 pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
68 ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
69 ofpdrv->shutdown(pdev);
70}
71
72/**
73 * of_register_platform_driver
74 */
75int of_register_platform_driver(struct of_platform_driver *drv)
76{
77 char *of_name;
78
79 /* setup of_platform_driver to platform_driver adaptors */
80 drv->platform_driver.driver = drv->driver;
81
82 /* Prefix the driver name with 'of:' to avoid namespace collisions
83 * and bogus matches. There are some drivers in the tree that
84 * register both an of_platform_driver and a platform_driver with
85 * the same name. This is a temporary measure until they are all
86 * cleaned up --gcl July 29, 2010 */
87 of_name = kmalloc(strlen(drv->driver.name) + 5, GFP_KERNEL);
88 if (!of_name)
89 return -ENOMEM;
90 sprintf(of_name, "of:%s", drv->driver.name);
91 drv->platform_driver.driver.name = of_name;
92
93 if (drv->probe)
94 drv->platform_driver.probe = platform_driver_probe_shim;
95 drv->platform_driver.remove = drv->remove;
96 if (drv->shutdown)
97 drv->platform_driver.shutdown = platform_driver_shutdown_shim;
98 drv->platform_driver.suspend = drv->suspend;
99 drv->platform_driver.resume = drv->resume;
100
101 return platform_driver_register(&drv->platform_driver);
102}
103EXPORT_SYMBOL(of_register_platform_driver);
104
105void of_unregister_platform_driver(struct of_platform_driver *drv)
106{
107 platform_driver_unregister(&drv->platform_driver);
108 kfree(drv->platform_driver.driver.name);
109 drv->platform_driver.driver.name = NULL;
110}
111EXPORT_SYMBOL(of_unregister_platform_driver);
112
113#if defined(CONFIG_PPC_DCR) 45#if defined(CONFIG_PPC_DCR)
114#include <asm/dcr.h> 46#include <asm/dcr.h>
115#endif 47#endif
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 048949fa1d10..17c7e21c0bd7 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -23,13 +23,7 @@
23 * of_platform_driver - Legacy of-aware driver for platform devices. 23 * of_platform_driver - Legacy of-aware driver for platform devices.
24 * 24 *
25 * An of_platform_driver driver is attached to a basic platform_device on 25 * An of_platform_driver driver is attached to a basic platform_device on
26 * ether the "platform bus" (platform_bus_type), or the ibm ebus 26 * the ibm ebus (ibmebus_bus_type).
27 * (ibmebus_bus_type).
28 *
29 * of_platform_driver is being phased out when used with the platform_bus_type,
30 * and regular platform_drivers should be used instead. When the transition
31 * is complete, only ibmebus will be using this structure, and the
32 * platform_driver member of this structure will be removed.
33 */ 27 */
34struct of_platform_driver 28struct of_platform_driver
35{ 29{
@@ -42,15 +36,11 @@ struct of_platform_driver
42 int (*shutdown)(struct platform_device* dev); 36 int (*shutdown)(struct platform_device* dev);
43 37
44 struct device_driver driver; 38 struct device_driver driver;
45 struct platform_driver platform_driver;
46}; 39};
47#define to_of_platform_driver(drv) \ 40#define to_of_platform_driver(drv) \
48 container_of(drv,struct of_platform_driver, driver) 41 container_of(drv,struct of_platform_driver, driver)
49 42
50/* Platform drivers register/unregister */ 43/* Platform drivers register/unregister */
51extern int of_register_platform_driver(struct of_platform_driver *drv);
52extern void of_unregister_platform_driver(struct of_platform_driver *drv);
53
54extern struct platform_device *of_device_alloc(struct device_node *np, 44extern struct platform_device *of_device_alloc(struct device_node *np,
55 const char *bus_id, 45 const char *bus_id,
56 struct device *parent); 46 struct device *parent);