lkml.org 
[lkml]   [2011]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC 1/2] serial: Add OF alias support for uartlite
Date
Signed-off-by: John Williams <john.williams@petalogix.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
---
drivers/tty/serial/uartlite.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 0aed022..71ba422 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -573,13 +573,31 @@ MODULE_DEVICE_TABLE(of, ulite_of_match);
static int __devinit ulite_probe(struct platform_device *pdev)
{
struct resource *res, *res2;
+ unsigned int *idp;
int id = pdev->id;
+
#ifdef CONFIG_OF
- const __be32 *prop;
+ /* Look for a serialN alias */
+ id = of_alias_get_id(pdev->dev.of_node, "serial");
+ if (id < 0) {
+ dev_warn(&pdev->dev, "failed to get alias id, errno %d\n", id);
+ /* Fall back to old port-number property */
+ idp = of_get_property(pdev->dev.of_node, "port-number", NULL);
+ if (idp < 0) {
+ dev_warn(&pdev->dev,
+ "failed to get port-number, errno %d\n", idp);
+ id = -1;
+ } else
+ id = be32_to_cpup(idp);
+ }

- prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
- if (prop)
- id = be32_to_cpup(prop);
+ /* We can't register ids which are greater than number of uartlites */
+ if (id >= ULITE_NR_UARTS) {
+ dev_warn(&op->dev,
+ "Extern number of allocated uartlite entries "
+ "ULITE_NR_UARTS, id %d\n", id);
+ return -ENODEV;
+ }
#endif

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.5.4


\
 
 \ /
  Last update: 2011-11-08 14:37    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean