From patchwork Sat Apr 5 00:23:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 3941581 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 B1B9E9F1EE for ; Sat, 5 Apr 2014 00:25:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E5AEA20381 for ; Sat, 5 Apr 2014 00:25:12 +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 07F8820225 for ; Sat, 5 Apr 2014 00:25:12 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWEPj-0006ch-CK; Sat, 05 Apr 2014 00:24:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWEPb-0002sj-Ir; Sat, 05 Apr 2014 00:24:43 +0000 Received: from mail-qc0-x233.google.com ([2607:f8b0:400d:c01::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WWEPJ-0002my-Lx for linux-arm-kernel@lists.infradead.org; Sat, 05 Apr 2014 00:24:26 +0000 Received: by mail-qc0-f179.google.com with SMTP id m20so4317231qcx.10 for ; Fri, 04 Apr 2014 17:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fc+BnbQ9VIJjn5RQpxcg4UiDW/n3G33d9lKdL8QwUOM=; b=csffap9EFk4cGp7cvQQTO/GOikhTzsQkoRZlEB2Bz/yEkc/JceXeHlV60DxuKBfGKX XXDMG+RyAh+nsddOYaxAr7PxP/7H9sTE4tD3WINSKTmcuVWrN6uHMAtPldARxULzfwo4 r0Y7v3C/Uc+TgxGKOGlCeNLYQUeJ3+oc0O89s5Dx9iCtnrYqtdY2KUYaM4aX/shCQuxJ TaI4n7m2P5NMQ84oEVrFT1m7uXklMtUPqpWzRpJS/GK/bs79uxFfvTWT8PSMLaWvgEx4 tGHS335368+dq0eARuHSidSRik+SCcbVQGe9NFwJ6W6JHoGqjBQKHXfXsOKld/Ll15cz eZrQ== X-Received: by 10.140.80.209 with SMTP id c75mr16922764qgd.79.1396657442137; Fri, 04 Apr 2014 17:24:02 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id g92sm13165366qge.7.2014.04.04.17.24.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 04 Apr 2014 17:24:01 -0700 (PDT) From: Soren Brinkmann To: Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Randy Dunlap , Russell King , Michal Simek , Greg Kroah-Hartman , Jiri Slaby , Grant Likely Subject: [RESEND PATCH v3 2/9] tty: xuartps: Initialize ports according to aliases Date: Fri, 4 Apr 2014 17:23:38 -0700 Message-Id: <1396657425-31029-2-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 1.9.1.1.gbb9f595 In-Reply-To: <1396657425-31029-1-git-send-email-soren.brinkmann@xilinx.com> References: <1396657425-31029-1-git-send-email-soren.brinkmann@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140404_202425_763138_F604169C X-CRM114-Status: GOOD ( 17.03 ) X-Spam-Score: -1.9 (-) Cc: One Thousand Gnomes , Peter Crosthwaite , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, Soren Brinkmann 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,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Michal Simek 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 Signed-off-by: Soren Brinkmann --- 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");