From: Grant Likely <grant.likely@secretlab.ca>
To: sfr@canb.auug.org.au, devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org, monstr@monstr.eu
Subject: [PATCH] of/platform: Register of_platform_drivers with an "of:" prefix
Date: Thu, 29 Jul 2010 17:57:41 -0600 [thread overview]
Message-ID: <20100729235741.19423.77412.stgit@angua> (raw)
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.
---
drivers/of/platform.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index da10181..a6dbfd5 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -74,8 +74,22 @@ static void platform_driver_shutdown_shim(struct platform_device *pdev)
*/
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;
@@ -91,6 +105,8 @@ 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);
reply other threads:[~2010-07-29 23:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100729235741.19423.77412.stgit@angua \
--to=grant.likely@secretlab.ca \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox