|
@@ -42,74 +42,6 @@ struct platform_device *of_find_device_by_node(struct device_node *np)
|
|
|
}
|
|
|
EXPORT_SYMBOL(of_find_device_by_node);
|
|
|
|
|
|
-static int platform_driver_probe_shim(struct platform_device *pdev)
|
|
|
-{
|
|
|
- struct platform_driver *pdrv;
|
|
|
- struct of_platform_driver *ofpdrv;
|
|
|
- const struct of_device_id *match;
|
|
|
-
|
|
|
- pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
|
|
|
- ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
|
|
|
-
|
|
|
- /* There is an unlikely chance that an of_platform driver might match
|
|
|
- * on a non-OF platform device. If so, then of_match_device() will
|
|
|
- * come up empty. Return -EINVAL in this case so other drivers get
|
|
|
- * the chance to bind. */
|
|
|
- match = of_match_device(pdev->dev.driver->of_match_table, &pdev->dev);
|
|
|
- return match ? ofpdrv->probe(pdev, match) : -EINVAL;
|
|
|
-}
|
|
|
-
|
|
|
-static void platform_driver_shutdown_shim(struct platform_device *pdev)
|
|
|
-{
|
|
|
- struct platform_driver *pdrv;
|
|
|
- struct of_platform_driver *ofpdrv;
|
|
|
-
|
|
|
- pdrv = container_of(pdev->dev.driver, struct platform_driver, driver);
|
|
|
- ofpdrv = container_of(pdrv, struct of_platform_driver, platform_driver);
|
|
|
- ofpdrv->shutdown(pdev);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * of_register_platform_driver
|
|
|
- */
|
|
|
-int of_register_platform_driver(struct of_platform_driver *drv)
|
|
|
-{
|
|
|
- char *of_name;
|
|
|
-
|
|
|
- /* setup of_platform_driver to platform_driver adaptors */
|
|
|
- drv->platform_driver.driver = drv->driver;
|
|
|
-
|
|
|
- /* Prefix the driver name with 'of:' to avoid namespace collisions
|
|
|
- * and bogus matches. There are some drivers in the tree that
|
|
|
- * register both an of_platform_driver and a platform_driver with
|
|
|
- * the same name. This is a temporary measure until they are all
|
|
|
- * cleaned up --gcl July 29, 2010 */
|
|
|
- of_name = kmalloc(strlen(drv->driver.name) + 5, GFP_KERNEL);
|
|
|
- if (!of_name)
|
|
|
- return -ENOMEM;
|
|
|
- sprintf(of_name, "of:%s", drv->driver.name);
|
|
|
- drv->platform_driver.driver.name = of_name;
|
|
|
-
|
|
|
- if (drv->probe)
|
|
|
- drv->platform_driver.probe = platform_driver_probe_shim;
|
|
|
- drv->platform_driver.remove = drv->remove;
|
|
|
- if (drv->shutdown)
|
|
|
- drv->platform_driver.shutdown = platform_driver_shutdown_shim;
|
|
|
- drv->platform_driver.suspend = drv->suspend;
|
|
|
- drv->platform_driver.resume = drv->resume;
|
|
|
-
|
|
|
- return platform_driver_register(&drv->platform_driver);
|
|
|
-}
|
|
|
-EXPORT_SYMBOL(of_register_platform_driver);
|
|
|
-
|
|
|
-void of_unregister_platform_driver(struct of_platform_driver *drv)
|
|
|
-{
|
|
|
- platform_driver_unregister(&drv->platform_driver);
|
|
|
- kfree(drv->platform_driver.driver.name);
|
|
|
- drv->platform_driver.driver.name = NULL;
|
|
|
-}
|
|
|
-EXPORT_SYMBOL(of_unregister_platform_driver);
|
|
|
-
|
|
|
#if defined(CONFIG_PPC_DCR)
|
|
|
#include <asm/dcr.h>
|
|
|
#endif
|