Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932179AbaAWOp0 (ORCPT ); Thu, 23 Jan 2014 09:45:26 -0500 Received: from mail-we0-f172.google.com ([74.125.82.172]:35104 "EHLO mail-we0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754651AbaAWOpY (ORCPT ); Thu, 23 Jan 2014 09:45:24 -0500 From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Cc: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] tty: uartps: Initialize ports according to aliases Date: Thu, 23 Jan 2014 15:45:14 +0100 Message-Id: X-Mailer: git-send-email 1.8.2.3 Content-Type: multipart/signed; boundary="=_mimegpg-monstr-desktop-14580-1390488314-0001"; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a MIME GnuPG-signed message. If you see this text, it means that your E-mail or Usenet software does not support MIME signed messages. The Internet standard for MIME PGP messages, RFC 2015, was published in 1996. To open this message correctly you will need to install E-mail or Usenet software that supports modern Internet standards. --=_mimegpg-monstr-desktop-14580-1390488314-0001 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. Signed-off-by: Michal Simek --- drivers/tty/serial/xilinx_uartps.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 528f16a..8c09a3b 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1038,10 +1038,20 @@ static struct uart_port *xuartps_get_port(void) 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; + /* 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); + id = 0; + } + + /* 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; -- 1.8.2.3 --=_mimegpg-monstr-desktop-14580-1390488314-0001 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEABECAAYFAlLhKvsACgkQykllyylKDCGoIQCgkqzySLb5nJoRmfTtypnfgcnK jo4AnjWkVrxmkbjKbTUhOmZx+FLnI1Wp =ylaN -----END PGP SIGNATURE----- --=_mimegpg-monstr-desktop-14580-1390488314-0001-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/