From patchwork Fri Jul 21 09:32:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 9856381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51E5E601C0 for ; Fri, 21 Jul 2017 09:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4046F28749 for ; Fri, 21 Jul 2017 09:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3176828778; Fri, 21 Jul 2017 09:34:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC9F828749 for ; Fri, 21 Jul 2017 09:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H57qtUlO40ULjxtm/dbZT+9ipQKfm1iL01FMlHa3D7o=; b=NRkd6j2HUEkrbuWWlEzbiyHl9p aflWcfWacm5YMosqA4dbeN5nNu+lUEPb10xLhA2odCWMMFn/kN77ehtEPz0we8f2FTfk1tV2tLwVg P+hDC1mM5RvRM37B4d8IN16W37adR/ekpEeXrDzOYGqbb538icFBDJPWyvQqckPnzINAu3O5PeeQB YEa27YOsTlUb5C79uRYwQFJzfGzYyn5c/BLLBNFwJ97n7PIb/OyhqICkr6Th/+0lTb5mi2KnYS3k7 TvDw0QCPd1+hvamxwocz/pez3aic1Ju8RwYCTDO0+7bTunhbv8vEJP5COvXA+tbgOuULMlvIePUhJ TbK6IoDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dYUKg-0008GJ-AM; Fri, 21 Jul 2017 09:34:50 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dYUIr-00075B-7C for linux-arm-kernel@lists.infradead.org; Fri, 21 Jul 2017 09:32:59 +0000 Received: by mail-wm0-x242.google.com with SMTP id 143so6284295wmu.5 for ; Fri, 21 Jul 2017 02:32:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IBDnPgzVwkRN8eqY9qwXi+pbba/lkBaQE2CL36nugM0=; b=1CQgliGl/br34MYINQNRWZxKQTlfdoue+TBlzI+6LvEtiAvlnU2LJJbsQ7OhXfMNe9 v8XUXfjNyTUpmwKkKjqGXrykUbJGi8TUPxZqyv9idO+hqVhPJVYRg9vcA825sA8vhc5r nNTSWZHsWj4YejeiJ7ivckm137COfbPeLPzpk5FkgajS5RiwJz6DLRczo51wfutGbFN2 pTLrChilGJklmyoEPtzv+ZjPAu6uOcgQPbDDDVZ8fHWL7H3zLP2bEXyAwbaIvf5dx70S KRINBMMZnAPbapoUUei8aePyGijS35V2dqCafSFBaFe5ZtxkxLoSvTh6U4K/od9ZQR0l AILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=IBDnPgzVwkRN8eqY9qwXi+pbba/lkBaQE2CL36nugM0=; b=cT8WGMr6PCkXXWtiQgkGhEmPh/rlj7pm49k/SFWaSrUnxtFNgjWwsPf2ngMPCvRjEp gWmvOfJgVmhRQ8sXfjd6jgP/5oIDpYhJaz6S/Riyi4X0Xd12XowGUsjxG8245TidhboM FTwqY7FtZHExV9l/0KcuMFpQ63/B9W7iWIhejVFodC5H8NJaEfvG6Vb5OiudIJcutbpx qwW/WYAFokVf2Q0wrrMB1ezxpJOxz+Zkm3aQgX4fOM2cWFnVkB9ZQ1QEYXYwKraOKUQt 2uq+H+7IoxYB5OGIrv6CrZMGpokOPebDdzS82XkVgidJ2KlE4PSwuphGZh6Z1peK2BEq HeZw== X-Gm-Message-State: AIVw113ols5yhAbeQSjN8mMqjNiigWrm0y8+4eZLzTfhNZyoaQAguuhn ay+oePJtFu8kxvS8 X-Received: by 10.28.187.86 with SMTP id l83mr4517895wmf.165.1500629555442; Fri, 21 Jul 2017 02:32:35 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id j137sm1422611wmf.43.2017.07.21.02.32.34 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 21 Jul 2017 02:32:34 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, Alan Cox Subject: [RFC PATCH 3/4] serial: uartps: Move cnds_uart_get_port to probe Date: Fri, 21 Jul 2017 11:32:26 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170721_023257_480153_1FE7D2C7 X-CRM114-Status: GOOD ( 14.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , linux-serial@vger.kernel.org, =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , Jiri Slaby MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP c&p this function to probe as preparation for removing cdns_uart_port[] static array. Signed-off-by: Michal Simek --- drivers/tty/serial/xilinx_uartps.c | 61 +++++++++++++------------------------- 1 file changed, 21 insertions(+), 40 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e6470a3111ce..4fb74baeae35 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1104,43 +1104,6 @@ static void cdns_uart_pm(struct uart_port *port, unsigned int state, static struct uart_port cdns_uart_port[CDNS_UART_NR_PORTS]; -/** - * cdns_uart_get_port - Configure the port from platform device resource info - * @id: Port id - * - * Return: a pointer to a uart_port or NULL for failure - */ -static struct uart_port *cdns_uart_get_port(int id) -{ - struct uart_port *port; - - /* Try the given port id if failed use default method */ - if (cdns_uart_port[id].mapbase != 0) { - /* Find the next unused port */ - for (id = 0; id < CDNS_UART_NR_PORTS; id++) - if (cdns_uart_port[id].mapbase == 0) - break; - } - - if (id >= CDNS_UART_NR_PORTS) - return NULL; - - port = &cdns_uart_port[id]; - - /* At this point, we've got an empty uart_port struct, initialize it */ - spin_lock_init(&port->lock); - port->membase = NULL; - port->irq = 0; - port->type = PORT_UNKNOWN; - port->iotype = UPIO_MEM32; - port->flags = UPF_BOOT_AUTOCONF; - port->ops = &cdns_uart_ops; - port->fifosize = CDNS_UART_FIFO_SIZE; - port->line = id; - port->dev = NULL; - return port; -} - #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /** * cdns_uart_console_wait_tx - Wait for the TX to be full @@ -1545,15 +1508,33 @@ static int cdns_uart_probe(struct platform_device *pdev) if (id < 0) id = 0; - /* Initialize the port structure */ - port = cdns_uart_get_port(id); + /* Try the given port id if failed use default method */ + if (cdns_uart_port[id].mapbase != 0) { + /* Find the next unused port */ + for (id = 0; id < CDNS_UART_NR_PORTS; id++) + if (cdns_uart_port[id].mapbase == 0) + break; + } - if (!port) { + port = &cdns_uart_port[id]; + if (!port || id >= CDNS_UART_NR_PORTS) { dev_err(&pdev->dev, "Cannot get uart_port structure\n"); rc = -ENODEV; goto err_out_notif_unreg; } + /* At this point, we've got an empty uart_port struct, initialize it */ + spin_lock_init(&port->lock); + port->membase = NULL; + port->irq = 0; + port->type = PORT_UNKNOWN; + port->iotype = UPIO_MEM32; + port->flags = UPF_BOOT_AUTOCONF; + port->ops = &cdns_uart_ops; + port->fifosize = CDNS_UART_FIFO_SIZE; + port->line = id; + port->dev = NULL; + /* * Register the port. * This function also registers this device with the tty layer