From: Michal Simek <monstr@monstr.eu>
To: devicetree-discuss@lists.ozlabs.org
Cc: grant.likely@secretlab.ca, john.williams@petalogix.com,
michal.simek@petalogix.com, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, jacmet@sunsite.dk, arnd@arndb.de
Subject: [RFC 1/2] serial: Add OF alias support for uartlite
Date: Tue, 8 Nov 2011 14:35:06 +0100 [thread overview]
Message-ID: <1320759307-24877-2-git-send-email-monstr@monstr.eu> (raw)
In-Reply-To: <1320759307-24877-1-git-send-email-monstr@monstr.eu>
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
next prev parent reply other threads:[~2011-11-08 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 13:35 [RFC 0/2] serial: OF alias support Michal Simek
2011-11-08 13:35 ` Michal Simek [this message]
[not found] ` <1320759307-24877-2-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-11-08 13:35 ` [RFC 2/2] serial: 8250: Add " Michal Simek
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=1320759307-24877-2-git-send-email-monstr@monstr.eu \
--to=monstr@monstr.eu \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=jacmet@sunsite.dk \
--cc=john.williams@petalogix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=michal.simek@petalogix.com \
/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).