lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue,  8 Nov 2011 14:35:06 +0100
From:	Michal Simek <monstr@...str.eu>
To:	devicetree-discuss@...ts.ozlabs.org
Cc:	grant.likely@...retlab.ca, john.williams@...alogix.com,
	michal.simek@...alogix.com, linux-kernel@...r.kernel.org,
	linux-serial@...r.kernel.org, jacmet@...site.dk, arnd@...db.de
Subject: [RFC 1/2] serial: Add OF alias support for uartlite

Signed-off-by: John Williams <john.williams@...alogix.com>
Signed-off-by: Michal Simek <monstr@...str.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ