From patchwork Mon Apr 23 09:51:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10356543 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 A825F6019D for ; Mon, 23 Apr 2018 09:56:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9647828A03 for ; Mon, 23 Apr 2018 09:56:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A79628A0C; Mon, 23 Apr 2018 09:56:02 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 1D53028A03 for ; Mon, 23 Apr 2018 09:56:02 +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=3ZkTihI6e2IJXHbR6buQP301jaPBiBnt0ieK5xJg9pc=; b=a+PP1g0/k+V451FvEfdOJ2MwiS sSFWXajzQouO4AzCpdolJO/Ju16NykGrb5sMUt2nk84M5gnoJ7UXggxSg/AsxE8x6ceZJwsdeuS79 uoo+3MmgwvhCBDgUl8D9aTe3jc5C021eKtzJ8nYplodtT24QFKHnyjqFvW32ho12tlzbL+hvKx8tV 5kgTBKkFbZhG6uFo2IfxSCXE86op9dizoAKLXEaRCJ/FcKCcDc6z5rogSp9d3u7nvGlgwvhjY4eOD qapbPyMqeRbrXxTF3kOWqj15Km08uT36osQoGQFZTKDMe5kLsWpYIMWuOik5S51FP6nWoGkcyemoV Z+qfo7/Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAYCR-0005x6-8C; Mon, 23 Apr 2018 09:55:55 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAY7y-0002mp-9N for linux-arm-kernel@lists.infradead.org; Mon, 23 Apr 2018 09:51:31 +0000 Received: by mail-wr0-x241.google.com with SMTP id h3-v6so39440983wrh.5 for ; Mon, 23 Apr 2018 02:51:10 -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=asBMB1AX+PYiJ4s19UgStFvDPvPBLW/XZRI4sT+gkc0=; b=Z4FiKGti7y3jlaiMnQNOqp8fZQr5+BzcvrqujDMmI9tVc0Toc4A2zvZdaYijzKYn3F KTexyk2mN7uWo2n9ixmVJeM5JvLlqg+iDYW6XwmnR4B9uxH+L2FrAhykujBhA4wVZZAK 3fypDPMXzhV1ppQUt4vf8p8pFgJKHZ2pJryJWIxf0RM7LW2Pde2p6jdu9bewUuyQGonG DKxR3REzCQA0hqbuavCHtGI2dztKFQpAIENlzNugXzxvk8jSFb6N4W5QqW0OSVQ24nOH MqYB0Tzlac6SgWAfng4WVMKm87awYsIxnRTp9KwHdQytqjAdt3Ztm9GxIWU8UHCYmhGq Khww== 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=asBMB1AX+PYiJ4s19UgStFvDPvPBLW/XZRI4sT+gkc0=; b=kALZSytikTERXx6XIytxFObeJurn2QrPTLDePUaXE3dnml/wzx+WmSnzJbZx4ZPfeB +fuZBv+9+65yNa0HZ3L3pfBz57tv4e5nPq/K/bS3UPAwRK9SzdVEpjjVaU6g41/arD6I VXZQY6J5HapUKD6xXi4WB2Ejaw4RA0EnjtpPQYA85ih+Wivs38GR3h+DFyKoANshPQiD jEJIwFloj/TsnSF8c55mDj9faIXtET+/wHmmJJZ25uEFQP0oTjyAj1Viug+KXUboWC0I QMEI7kkIjjuYf+BjNaTFfe/QZQegTwB7aNZjU0Vh8C8X1Lncj4ITJdLugpmmPAGXCveX q3sA== X-Gm-Message-State: ALQs6tAYjCi/+yC2WvZ8ytOnfCf81jc44O/WXUx4qox6edxZJ4ZmClXS F1Wo1Q5cnern6c3v+yGjIVpK0kwm X-Google-Smtp-Source: AB8JxZpuKncGDq7mRmLjDmhrcV3XdNInPCGGE84bbSRTQiN4ljKtlIVR3s5CtO09dTXPUGbhQBJg/g== X-Received: by 10.28.109.80 with SMTP id i77mr8634304wmc.46.1524477068938; Mon, 23 Apr 2018 02:51:08 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id r19-v6sm10966693wrg.8.2018.04.23.02.51.08 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 23 Apr 2018 02:51:08 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, Alan Cox , geert+renesas@glider.be Subject: [PATCH 3/4] serial: uartps: Move cnds_uart_get_port to probe Date: Mon, 23 Apr 2018 11:51:02 +0200 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180423_025118_366416_20341199 X-CRM114-Status: GOOD ( 15.50 ) 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: Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, 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 Reviewed-by: Alan Cox --- 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 789423d081ed..f7d527a1c532 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1099,43 +1099,6 @@ static const struct uart_ops cdns_uart_ops = { 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 (id < CDNS_UART_NR_PORTS && 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 @@ -1540,15 +1503,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 (id < CDNS_UART_NR_PORTS && 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