From patchwork Thu Jan 23 15:06:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3529541 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 22A4BC02DC for ; Thu, 23 Jan 2014 15:07:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10BA9200FF for ; Thu, 23 Jan 2014 15:07: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 C5FCD200E9 for ; Thu, 23 Jan 2014 15:07:10 +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 1W6Lrz-0003Wa-UK; Thu, 23 Jan 2014 15:07:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W6Lrx-0003ab-DK; Thu, 23 Jan 2014 15:07:01 +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 1W6Lrv-0003Yq-ES for linux-arm-kernel@lists.infradead.org; Thu, 23 Jan 2014 15:07:00 +0000 Received: by mail-wg0-f47.google.com with SMTP id m15so1643316wgh.14 for ; Thu, 23 Jan 2014 07:06:37 -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=qQH7YBnESfZLW4Wa3qbPUx9i1sYCeJNoQ+GyKT2XIX4=; b=d2v1F17GXUDT/57HTrS0bNEtQ8SBc6ac7uuGRBqfwsKf4w5yqO9kKrfbWMufO3wO5s 76imwcl6Nliimsf6D5ZLSzsI3L8XZyLEv42rkmE7g+YIu2JOTtnTv4nxXzZ+cdn+cOEl 1pP1Z5gXbMy5+dxDop6BIk0MDbcsUmgmddmYMBAJryxFE4Va/QqIX323zAZMk+wM7/uw afE7b/4EM6ImiA4v4UtYB9QEREak6vdkEzY7WXkcXBZqWPI84uUY5wHfySW4OSGXZ6r2 Ze92ugikcabJj5OLmH6yK7Q66cPrdD5hGtWJeLM0H2yLvNZbFKHP9zVlmxWGS8fCb9YB Z1zw== X-Gm-Message-State: ALoCoQmhhDDUQ3O/WE3xhxra67R+D6ClNKrG0XWUa4AYfAPUsKdQsJZOvBE1C80JWs2mYaRkgcly X-Received: by 10.180.103.227 with SMTP id fz3mr24559799wib.29.1390489597604; Thu, 23 Jan 2014 07:06:37 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id ay6sm23021074wjb.23.2014.01.23.07.06.35 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 23 Jan 2014 07:06:36 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v2] tty: uartps: Initialize ports according to aliases Date: Thu, 23 Jan 2014 16:06:33 +0100 Message-Id: <225c74aa791dc09c72267f6718323cbcc36fef95.1390489583.git.michal.simek@xilinx.com> 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_100659_599506_D840DA36 X-CRM114-Status: GOOD ( 18.26 ) 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 --- This patch should by applied on the top of: http://www.spinics.net/lists/arm-kernel/msg302143.html http://www.spinics.net/lists/arm-kernel/msg302144.html Changes in v2: - Fix my fault by sending incorrect version drivers/tty/serial/xilinx_uartps.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) -- 1.8.2.3 diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 528f16a..d8f46e8 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; @@ -1333,6 +1337,7 @@ static int xuartps_probe(struct platform_device *pdev) struct uart_port *port; struct resource *res, *res2; struct xuartps *xuartps_data; + int id; xuartps_data = devm_kzalloc(&pdev->dev, sizeof(*xuartps_data), GFP_KERNEL); @@ -1380,9 +1385,15 @@ 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) { + dev_warn(&pdev->dev, "failed to get alias id, errno %d\n", id); + 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");