Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5263a51 authored by Grant Likely's avatar Grant Likely
Browse files

dt: uartlite: merge platform and of_platform driver bindings



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: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarPeter Korsgaard <jacmet@sunsite.dk>
parent 55f19d56
Loading
Loading
Loading
Loading
+24 −79
Original line number Diff line number Diff line
@@ -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,29 @@ 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;
	int id = pdev->id;
#ifdef CONFIG_OF
	const __be32 *prop;

	prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
	if (prop)
		id = be32_to_cpup(prop);
#endif

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
@@ -583,7 +592,7 @@ static int __devinit ulite_probe(struct platform_device *pdev)
	if (!res2)
		return -ENODEV;

	return ulite_assign(&pdev->dev, pdev->id, res->start, res2->start);
	return ulite_assign(&pdev->dev, id, res->start, res2->start);
}

static int __devexit ulite_remove(struct platform_device *pdev)
@@ -600,67 +609,10 @@ static struct platform_driver ulite_platform_driver = {
	.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),
	.driver = {
		.name = "uartlite",
		.owner = THIS_MODULE,
		.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);
}