From: Grant Likely <grant.likely@secretlab.ca>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
devicetree-discuss@lists.ozlabs.org, sfr@canb.auug.org.au,
linux-kernel@vger.kernel.org, davem@davemloft.net
Cc: sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [RFC PATCH 07/15] dt: uartlite: merge platform and of_platform driver bindings
Date: Tue, 22 Feb 2011 21:34:11 -0700 [thread overview]
Message-ID: <20110223043411.20795.57850.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20110223043015.20795.37090.stgit@localhost6.localdomain6>
of_platform_driver is getting removed, and a single platform_driver
can now support both devicetree and non-devicetree use cases. This
patch merges the two driver registrations.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/tty/serial/uartlite.c | 103 ++++++++++-------------------------------
1 files changed, 24 insertions(+), 79 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index d2fce86..457ac34 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -19,22 +19,11 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <asm/io.h>
-#if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE))
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
-/* Match table for of_platform binding */
-static struct of_device_id ulite_of_match[] __devinitdata = {
- { .compatible = "xlnx,opb-uartlite-1.00.b", },
- { .compatible = "xlnx,xps-uartlite-1.00.a", },
- {}
-};
-MODULE_DEVICE_TABLE(of, ulite_of_match);
-
-#endif
-
#define ULITE_NAME "ttyUL"
#define ULITE_MAJOR 204
#define ULITE_MINOR 187
@@ -571,9 +560,23 @@ static int __devexit ulite_release(struct device *dev)
* Platform bus binding
*/
+#if defined(CONFIG_OF)
+/* Match table for of_platform binding */
+static struct of_device_id ulite_of_match[] __devinitdata = {
+ { .compatible = "xlnx,opb-uartlite-1.00.b", },
+ { .compatible = "xlnx,xps-uartlite-1.00.a", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, ulite_of_match);
+#else /* CONFIG_OF */
+#define ulite_of_match NULL
+#endif /* CONFIG_OF */
+
static int __devinit ulite_probe(struct platform_device *pdev)
{
struct resource *res, *res2;
+ const __be32 *prop;
+ int id = pdev->id;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -583,7 +586,13 @@ static int __devinit ulite_probe(struct platform_device *pdev)
if (!res2)
return -ENODEV;
- return ulite_assign(&pdev->dev, pdev->id, res->start, res2->start);
+#ifdef CONFIG_OF
+ prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
+ if (prop)
+ id = be32_to_cpup(prop);
+#endif
+
+ return ulite_assign(&pdev->dev, id, res->start, res2->start);
}
static int __devexit ulite_remove(struct platform_device *pdev)
@@ -595,72 +604,15 @@ static int __devexit ulite_remove(struct platform_device *pdev)
MODULE_ALIAS("platform:uartlite");
static struct platform_driver ulite_platform_driver = {
- .probe = ulite_probe,
- .remove = __devexit_p(ulite_remove),
- .driver = {
- .owner = THIS_MODULE,
- .name = "uartlite",
- },
-};
-
-/* ---------------------------------------------------------------------
- * OF bus bindings
- */
-#if defined(CONFIG_OF) && (defined(CONFIG_PPC32) || defined(CONFIG_MICROBLAZE))
-static int __devinit
-ulite_of_probe(struct platform_device *op, const struct of_device_id *match)
-{
- struct resource res;
- const unsigned int *id;
- int irq, rc;
-
- dev_dbg(&op->dev, "%s(%p, %p)\n", __func__, op, match);
-
- rc = of_address_to_resource(op->dev.of_node, 0, &res);
- if (rc) {
- dev_err(&op->dev, "invalid address\n");
- return rc;
- }
-
- irq = irq_of_parse_and_map(op->dev.of_node, 0);
-
- id = of_get_property(op->dev.of_node, "port-number", NULL);
-
- return ulite_assign(&op->dev, id ? *id : -1, res.start, irq);
-}
-
-static int __devexit ulite_of_remove(struct platform_device *op)
-{
- return ulite_release(&op->dev);
-}
-
-static struct of_platform_driver ulite_of_driver = {
- .probe = ulite_of_probe,
- .remove = __devexit_p(ulite_of_remove),
+ .probe = ulite_probe,
+ .remove = __devexit_p(ulite_remove),
.driver = {
- .name = "uartlite",
.owner = THIS_MODULE,
+ .name = "uartlite",
.of_match_table = ulite_of_match,
},
};
-/* Registration helpers to keep the number of #ifdefs to a minimum */
-static inline int __init ulite_of_register(void)
-{
- pr_debug("uartlite: calling of_register_platform_driver()\n");
- return of_register_platform_driver(&ulite_of_driver);
-}
-
-static inline void __exit ulite_of_unregister(void)
-{
- of_unregister_platform_driver(&ulite_of_driver);
-}
-#else /* CONFIG_OF && (CONFIG_PPC32 || CONFIG_MICROBLAZE) */
-/* Appropriate config not enabled; do nothing helpers */
-static inline int __init ulite_of_register(void) { return 0; }
-static inline void __exit ulite_of_unregister(void) { }
-#endif /* CONFIG_OF && (CONFIG_PPC32 || CONFIG_MICROBLAZE) */
-
/* ---------------------------------------------------------------------
* Module setup/teardown
*/
@@ -674,10 +626,6 @@ int __init ulite_init(void)
if (ret)
goto err_uart;
- ret = ulite_of_register();
- if (ret)
- goto err_of;
-
pr_debug("uartlite: calling platform_driver_register()\n");
ret = platform_driver_register(&ulite_platform_driver);
if (ret)
@@ -686,8 +634,6 @@ int __init ulite_init(void)
return 0;
err_plat:
- ulite_of_unregister();
-err_of:
uart_unregister_driver(&ulite_uart_driver);
err_uart:
printk(KERN_ERR "registering uartlite driver failed: err=%i", ret);
@@ -697,7 +643,6 @@ err_uart:
void __exit ulite_exit(void)
{
platform_driver_unregister(&ulite_platform_driver);
- ulite_of_unregister();
uart_unregister_driver(&ulite_uart_driver);
}
next prev parent reply other threads:[~2011-02-23 4:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-23 4:33 [RFC PATCH 00/15] Remove last remains of of_platform_bus_type Grant Likely
2011-02-23 4:33 ` [RFC PATCH 01/15] dt/powerpc: move of_bus_type infrastructure to ibmebus Grant Likely
2011-02-24 14:46 ` Arnd Bergmann
2011-02-25 8:53 ` Benjamin Herrenschmidt
2011-02-28 7:35 ` Grant Likely
2011-02-23 4:33 ` [RFC PATCH 02/15] dt: add a match table pointer to struct device Grant Likely
2011-02-23 18:29 ` Rob Herring
2011-02-23 18:44 ` Grant Likely
2011-02-23 21:18 ` Open Firmware and interrupt trigger Robert Thorhuus
2011-02-24 20:46 ` Benjamin Herrenschmidt
2011-02-25 7:29 ` Robert Thorhuus
2011-02-25 8:47 ` Benjamin Herrenschmidt
2011-02-23 4:33 ` [RFC PATCH 03/15] dt/powerpc: Eliminate users of of_platform_{, un}register_driver Grant Likely
2011-02-23 4:33 ` [RFC PATCH 04/15] dt/sparc: " Grant Likely
2011-02-23 4:34 ` [RFC PATCH 05/15] leds/leds-gpio: merge platform_driver with of_platform_driver Grant Likely
2011-02-23 4:34 ` [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and of_platform driver bindings Grant Likely
2011-02-25 18:25 ` [RFC PATCH 06/15] dt: xilinx_hwicap: merge platform and of_platformdriver bindings Stephen Neuendorffer
2011-02-28 7:41 ` Grant Likely
2011-02-23 4:34 ` Grant Likely [this message]
2011-02-23 8:58 ` [RFC PATCH 07/15] dt: uartlite: merge platform and of_platform driver bindings Peter Korsgaard
2011-02-23 18:10 ` Grant Likely
2011-02-23 4:34 ` [RFC PATCH 08/15] dt/spi: Eliminate users of of_platform_{, un}register_driver Grant Likely
2011-02-23 4:34 ` [RFC PATCH 09/15] dt/sound: " Grant Likely
2011-02-23 4:34 ` [RFC PATCH 10/15] dt/net: " Grant Likely
2011-02-23 4:34 ` [RFC PATCH 11/15] dt/video: " Grant Likely
2011-02-23 4:34 ` [RFC PATCH 12/15] dt/usb: " Grant Likely
2011-02-23 4:34 ` [RFC PATCH 13/15] dt/serial: " Grant Likely
2011-02-24 16:34 ` Arnd Bergmann
2011-02-23 4:34 ` [RFC PATCH 14/15] dt: Eliminate of_platform_{,un}register_driver Grant Likely
2011-02-23 16:56 ` Rob Herring
2011-02-23 17:22 ` Grant Likely
2011-02-23 4:34 ` [RFC PATCH 15/15] dt: eliminate of_platform_driver shim code Grant Likely
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=20110223043411.20795.57850.stgit@localhost6.localdomain6 \
--to=grant.likely@secretlab.ca \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sfr@canb.auug.org.au \
--cc=sparclinux@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).