From patchwork Thu Jan 23 14:45:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3529381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66EE39F1C3 for ; Thu, 23 Jan 2014 14:46:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6124520122 for ; Thu, 23 Jan 2014 14:46:55 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DD8220109 for ; Thu, 23 Jan 2014 14:46:54 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6LXx-0003Ii-9x; Thu, 23 Jan 2014 14:46:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6LXQ-0002mG-JC; Thu, 23 Jan 2014 14:45:48 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6LXN-0002lA-3Q for linux-arm-kernel@lists.infradead.org; Thu, 23 Jan 2014 14:45:45 +0000 Received: by mail-wg0-f47.google.com with SMTP id m15so1557917wgh.26 for ; Thu, 23 Jan 2014 06:45:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :content-type; bh=wDSpG3mB7ihHiV5g0iArQNpP1GlDhFSmK7tq938caRs=; b=AFBb1hpuykDkHVCDXioisXB0+s/dq9snekdc+7chWE7WHLq+mDce+r1uB05hCkF4WJ aH3QGQ1dpHiMzdJx70NUej0jI7HtusvbHDmdziBoq5qfqMPd+AFo/U2KI04HLNvcKe9Y 8DUhR7g/Ki4+gj3rB13H0gxKrOxYO8gbo0Kq5GuSVaublke7yJfkBHSUpTy4F7k84yCG b/FYre+nNtcyx05pddpZL2OWKjVXCjSpDyTpQnw3/+0QOIEPGv/dxmR8N83JxViVyxGj NaMDE4ZMwJs918+FyktWSjMOMcMWLZWvMImaK1IhhrbW+aGIpayKkuyaSJqBB9XDeez6 pttg== X-Gm-Message-State: ALoCoQkO8xPicqa079wzBE8bHENVpP8piYsI/SELCcO7WiZj3H4SxSuJ2xMcfvS+U6XXp55hsS5d X-Received: by 10.194.93.67 with SMTP id cs3mr7183238wjb.26.1390488323426; Thu, 23 Jan 2014 06:45:23 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id ux5sm22865734wjc.6.2014.01.23.06.45.21 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 23 Jan 2014 06:45:22 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140123_094545_233170_BB36B948 X-CRM114-Status: GOOD ( 15.74 ) X-Spam-Score: -1.9 (-) Cc: Greg Kroah-Hartman , Jiri Slaby , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) -- 1.8.2.3 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;