From patchwork Wed Mar 12 19:02:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 3820521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C760CBF540 for ; Wed, 12 Mar 2014 19:10:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 013EE202B4 for ; Wed, 12 Mar 2014 19:10:48 +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 F3CBF2027D for ; Wed, 12 Mar 2014 19:10:46 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNoXP-0002HH-6V; Wed, 12 Mar 2014 19:09:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNoSV-0000PT-M5; Wed, 12 Mar 2014 19:04:55 +0000 Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WNoS1-0000JV-MT for linux-arm-kernel@lists.infradead.org; Wed, 12 Mar 2014 19:04:27 +0000 Received: by mail-ig0-f174.google.com with SMTP id h18so15156886igc.1 for ; Wed, 12 Mar 2014 12:04:04 -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=iC+B7151BSMfNkW1afBrCFUNAIdNHDLy1oFNqZp/LcU=; b=BvIL0CzGGMgSkZZADvUXZ7bvs3VBczpirKFUr0nWmdc5w3r7mOyB+Xc/7kc3/CcFse 6hDt4yM6YiDkFaXfWDZWCEWNsL3Lm5Bovtm5kHiJUQbsfTyLVyuikspz7ZXtF5B6ei7I ZfMzX1Keeg6ZNsl0neMOLcB8/KeJTjKgGT5f0BvfSkUXD0DlNDogZZM1gs13NkYk6wln yLqq9ZQfPb490acNDJ8QyFxadUu84y/VqXYf/f+b/2JH9n+lBlfzTXawtmwWeWSff8bm Mu3CcIUBDx83d/yu1LG+xcHgBkQV/S+PnJ4hwHZ5OsknIwZkaACEgKFgtqq/bD3iOaMm DmTA== X-Received: by 10.50.43.194 with SMTP id y2mr30802864igl.33.1394651044339; Wed, 12 Mar 2014 12:04:04 -0700 (PDT) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id ai4sm60350777igd.3.2014.03.12.12.04.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Mar 2014 12:04:03 -0700 (PDT) From: Soren Brinkmann To: Russell King , Greg Kroah-Hartman , Jiri Slaby , One Thousand Gnomes Subject: [PATCH v3 2/9] tty: xuartps: Initialize ports according to aliases Date: Wed, 12 Mar 2014 12:02:56 -0700 Message-Id: <1394650983-24780-3-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 1.9.0.1.g4196000 In-Reply-To: <1394650983-24780-1-git-send-email-soren.brinkmann@xilinx.com> References: <1394650983-24780-1-git-send-email-soren.brinkmann@xilinx.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140312_150425_790103_8B58D0E9 X-CRM114-Status: GOOD ( 16.48 ) X-Spam-Score: -1.9 (-) Cc: Mark Rutland , devicetree@vger.kernel.org, Peter Crosthwaite , Rob Landley , Pawel Moll , Ian Campbell , linux-doc@vger.kernel.org, Michal Simek , linux-kernel@vger.kernel.org, Rob Herring , Soren Brinkmann , linux-serial@vger.kernel.org, Kumar Gala , Grant Likely , linux-arm-kernel@lists.infradead.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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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. --- 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");