of/platform: Register of_platform_drivers with an "of:" prefix
Currently there are some drivers in tree which register both a platform_driver and an of_platform_driver with the same name. This is a temporary situation until all the relevant of_platform_drivers are converted to be normal platform_drivers. Until then, this patch gives all the of_platform_drivers an "of:" prefix to protect against bogus matches and namespace conflicts.
This commit is contained in:
Родитель
22ae782f86
Коммит
7fb8f881c5
|
@ -74,8 +74,22 @@ static void platform_driver_shutdown_shim(struct platform_device *pdev)
|
||||||
*/
|
*/
|
||||||
int of_register_platform_driver(struct of_platform_driver *drv)
|
int of_register_platform_driver(struct of_platform_driver *drv)
|
||||||
{
|
{
|
||||||
|
char *of_name;
|
||||||
|
|
||||||
/* setup of_platform_driver to platform_driver adaptors */
|
/* setup of_platform_driver to platform_driver adaptors */
|
||||||
drv->platform_driver.driver = drv->driver;
|
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)
|
if (drv->probe)
|
||||||
drv->platform_driver.probe = platform_driver_probe_shim;
|
drv->platform_driver.probe = platform_driver_probe_shim;
|
||||||
drv->platform_driver.remove = drv->remove;
|
drv->platform_driver.remove = drv->remove;
|
||||||
|
@ -91,6 +105,8 @@ EXPORT_SYMBOL(of_register_platform_driver);
|
||||||
void of_unregister_platform_driver(struct of_platform_driver *drv)
|
void of_unregister_platform_driver(struct of_platform_driver *drv)
|
||||||
{
|
{
|
||||||
platform_driver_unregister(&drv->platform_driver);
|
platform_driver_unregister(&drv->platform_driver);
|
||||||
|
kfree(drv->platform_driver.driver.name);
|
||||||
|
drv->platform_driver.driver.name = NULL;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(of_unregister_platform_driver);
|
EXPORT_SYMBOL(of_unregister_platform_driver);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче