From: Soren Brinkmann <soren.brinkmann@xilinx.com>
To: Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Randy Dunlap <rdunlap@infradead.org>,
Russell King <linux@arm.linux.org.uk>,
Michal Simek <michal.simek@xilinx.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.cz>,
Grant Likely <grant.likely@linaro.org>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
Soren Brinkmann <soren.brinkmann@xilinx.com>,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-serial@vger.kernel.org
Subject: [RESEND PATCH v3 2/9] tty: xuartps: Initialize ports according to aliases
Date: Fri, 4 Apr 2014 17:23:38 -0700 [thread overview]
Message-ID: <1396657425-31029-2-git-send-email-soren.brinkmann@xilinx.com> (raw)
In-Reply-To: <1396657425-31029-1-git-send-email-soren.brinkmann@xilinx.com>
From: Michal Simek <michal.simek@xilinx.com>
Register port numbers according to order in DT aliases.
If aliases are not defined, order in DT is used.
If aliases are defined, register port id based
on that.
This patch ensures proper ttyPS0/1 assignment.
[soren]: Combined integer declarations in probe(), removed warning message
if no alias is found.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
The alias is an optional feature. Print a warning if it is not provided
does not seem appropriate.
Changes in v3: None
Changes in v2:
- this patch has been added
---
drivers/tty/serial/xilinx_uartps.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index b2f929e48ddd..2cd0cd456c7a 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1031,17 +1031,21 @@ static struct uart_port xuartps_port[2];
* xuartps_get_port - Configure the port from the platform device resource
* info
*
+ * @id: Port id
+ *
* Return: a pointer to a uart_port or NULL for failure
*/
-static struct uart_port *xuartps_get_port(void)
+static struct uart_port *xuartps_get_port(int id)
{
struct uart_port *port;
- int id;
- /* Find the next unused port */
- for (id = 0; id < XUARTPS_NR_PORTS; id++)
- if (xuartps_port[id].mapbase == 0)
- break;
+ /* Try the given port id if failed use default method */
+ if (xuartps_port[id].mapbase != 0) {
+ /* Find the next unused port */
+ for (id = 0; id < XUARTPS_NR_PORTS; id++)
+ if (xuartps_port[id].mapbase == 0)
+ break;
+ }
if (id >= XUARTPS_NR_PORTS)
return NULL;
@@ -1329,7 +1333,7 @@ static SIMPLE_DEV_PM_OPS(xuartps_dev_pm_ops, xuartps_suspend, xuartps_resume);
*/
static int xuartps_probe(struct platform_device *pdev)
{
- int rc;
+ int rc, id;
struct uart_port *port;
struct resource *res, *res2;
struct xuartps *xuartps_data;
@@ -1380,9 +1384,13 @@ static int xuartps_probe(struct platform_device *pdev)
&xuartps_data->clk_rate_change_nb))
dev_warn(&pdev->dev, "Unable to register clock notifier.\n");
#endif
+ /* Look for a serialN alias */
+ id = of_alias_get_id(pdev->dev.of_node, "serial");
+ if (id < 0)
+ id = 0;
/* Initialize the port structure */
- port = xuartps_get_port();
+ port = xuartps_get_port(id);
if (!port) {
dev_err(&pdev->dev, "Cannot get uart_port structure\n");
--
1.9.1.1.gbb9f595
next prev parent reply other threads:[~2014-04-05 0:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-05 0:23 [RESEND PATCH v3 1/9] tty: xuartps: Fix kernel-doc errors in the driver Soren Brinkmann
2014-04-05 0:23 ` Soren Brinkmann [this message]
2014-04-05 0:23 ` [RESEND PATCH v3 3/9] tty: xuartps: Clean up Soren Brinkmann
2014-04-05 0:23 ` [RESEND PATCH v3 4/9] tty: xuartps: Print warning in clock notifier Soren Brinkmann
2014-04-05 0:23 ` [RESEND PATCH v3 5/9] tty: xuartps: Refactor read-modify-writes Soren Brinkmann
2014-04-05 0:23 ` [RESEND PATCH v3 6/9] tty: xuartps: Don't write IRQ disable register to enable interrupts Soren Brinkmann
2014-04-05 0:23 ` [RESEND PATCH v3 7/9] tty: xuartps: Rebrand driver as Cadence UART Soren Brinkmann
2014-04-05 0:23 ` [RESEND PATCH v3 8/9] tty: cadence: Document DT binding Soren Brinkmann
2014-04-23 6:29 ` Michal Simek
2014-04-05 0:23 ` [RESEND PATCH v3 9/9] ARM: zynq: DT: Migrate UART to Cadence binding Soren Brinkmann
2014-04-23 6:29 ` Michal Simek
2014-04-18 16:11 ` [RESEND PATCH v3 1/9] tty: xuartps: Fix kernel-doc errors in the driver Sören Brinkmann
2014-04-24 23:22 ` Greg Kroah-Hartman
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=1396657425-31029-2-git-send-email-soren.brinkmann@xilinx.com \
--to=soren.brinkmann@xilinx.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jslaby@suse.cz \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=michal.simek@xilinx.com \
--cc=pawel.moll@arm.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=rdunlap@infradead.org \
--cc=robh+dt@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
all inboxes | Powered by JetHome®