From patchwork Mon Sep 3 13:10:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9132C139B for ; Mon, 3 Sep 2018 13:12:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CA5829341 for ; Mon, 3 Sep 2018 13:12:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D8FF29785; Mon, 3 Sep 2018 13:12:59 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 F288029341 for ; Mon, 3 Sep 2018 13:12:58 +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=Z+Jw1QrYTiCk+HcOxtoJMIkvpCqJ6p3L2rRN7nldJn8=; b=RwDZpYH8DRzxCjSNImVpHe6fjT B9EyQYa2/DHn3rddqT2uhzGKO+/OqRcsk39AScExOuytcH9DqF1UCB5E/AhNwJLVRmcClDGIeMO99 OpLB9tyAFpkw06f96IFg07LP/XfKh3vK/szJL48g3iAbFXHIHuWuTXwi8I72T498cZAeoEjx4e0y+ f/nQStXXB7pJHReZht4N5/Rcdjvv0q2bmK6vOlTKG+RXPuDiZUoC0ZpqTjjkHHkU3LxbM6S1SsuM5 xiJUO9ZPJZcDz54Wn+dzx9GDNjTYVdwfo3QaTVhMure+khMmhPh4HykIVSeV0xyn6SneFXOSMbevw wR/mx7NQ==; 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 1fwoet-0001Vx-Ui; Mon, 03 Sep 2018 13:12:48 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodN-0000pF-G9 for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:17 +0000 Received: by mail-wm0-x241.google.com with SMTP id s12-v6so1167864wmc.0 for ; Mon, 03 Sep 2018 06:11:02 -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=ZuPRWG0B4enQGXI2G2oBqHrb6zTd1Azps2shrb64GUU=; b=OYfUNFl57bmxosC7xk8Xsi/uLPSBLOLQHsj9lV3/vd1PlgzHq8xf5QHUir3BD7vs5j inDbwhjSAcuQTpWec61031DJl6KF7RLxKtzI6F3nRp233fIP0gOV8kkmCYlKZUNql9C8 +0NPKeg5OeTJPEiSViWy0QdK56ryGQOBQiABf5uo8rn7wPSr7xn1AfSYwDJy/nQGP4Cy 96VzOkBRfChYGe1QCK9zgr04OBRd9dBxrTp1P35STqGHW+rSiogqFp4b0ykycNI1cN8B 0H4lJ+wD5Ze5p9tRe4YgMBW1zOiW3n84NdMLCmt4EpYmq72VlaThXBD4C/7IugUp3RnC VbeQ== 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=ZuPRWG0B4enQGXI2G2oBqHrb6zTd1Azps2shrb64GUU=; b=EDzlTKDZ5HPiQfZq2QQA22sl7HICLbSL0yv0UnyK061lthQwknhc+aQ1v2UF5Tk3JR nswsbdaTuMKI4rpFi3XyDC73yMkHX4SnCLxwWDcZdTS6HjCqjrN7ex4F0WguX9bGIqMl Ka4kTsSVPvvDWw2OV19PJd9WRZQWIfDeft3uumc+oGYux+ajgK/AJkrNIFcmHOd2f+47 dq2sq3G8r/VHWOMkCAa6PT9cHQRxZI9GrV6TMgR8HKbc5eOFntEEEZ2KQIH/g11Mjow6 1e1mHnE3+1squmDR0u0Oa1OwcLIcTXUoUEuzMY2gLc8ctwsq0Co8MtMnMD9cJwGKRuZM ppXg== X-Gm-Message-State: APzg51A29rh4LH8xZFhvN+C546a4/cKmkkZH3GIjBC3G+NXPU5wJbLsU pMb/xQZdobeetrKgOBeY+y6sVg== X-Google-Smtp-Source: ANB0VdYWVBM+6Rh5h7FfDwqpBa0deOAjJ5zDnMFRER5EMLg6sEW0AKzPI9llykI4wfAhSa3J9ThFHA== X-Received: by 2002:a1c:cbc1:: with SMTP id b184-v6mr5423460wmg.149.1535980261568; Mon, 03 Sep 2018 06:11:01 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id a11-v6sm15592098wrr.81.2018.09.03.06.11.00 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:01 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 01/10] serial: uartps: console_setup() can't be placed to init section Date: Mon, 3 Sep 2018 15:10:49 +0200 Message-Id: <08b079a26d5b5393ed58f68e55acbb1f9afe1821.1535980253.git.michal.simek@xilinx.com> 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-20180903_061113_555935_8E7FA0E8 X-CRM114-Status: GOOD ( 15.36 ) 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 When console device is rebinded, console_setup() is called again. But marking it as __init means that function will be clear after boot is complete. If console device is binded again console_setup() is not found and error "Unable to handle kernel paging request at virtual address" is reported. Signed-off-by: Michal Simek --- Changes in v3: - New patch found by testing Changes in v2: None drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index e5d90611c03f..dd905c981f67 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1216,7 +1216,7 @@ static void cdns_uart_console_write(struct console *co, const char *s, * * Return: 0 on success, negative errno otherwise. */ -static int __init cdns_uart_console_setup(struct console *co, char *options) +static int cdns_uart_console_setup(struct console *co, char *options) { struct uart_port *port = console_port; From patchwork Mon Sep 3 13:10:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6745D14BD for ; Mon, 3 Sep 2018 13:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 559F8297B6 for ; Mon, 3 Sep 2018 13:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 473B3297C2; Mon, 3 Sep 2018 13:15:06 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 502BA297B6 for ; Mon, 3 Sep 2018 13:15:05 +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=YDjqBdfJ/L1zVkWhloinPnYlKr1a0EPSYSLFYWJAkH0=; b=tf2C+ha2/vyuj8vwj7t1nZbjbB hcVmQZNo4F5tllDYUT7a56SYa4da67sJ6EnNHnzk438uwrtKhMnI4i+77F1158n/f+mDnL9VStAZr 9dDDiGOJ2hFgzpCdm+VXxWfWPfaKdztM7ABadZ3NbanmkbdRrYuOnSL6TJ14j/keQsH8mAN3DN2p0 W9rEOqnh3PJfcW4k9fa4PFwxsTThi4neFKJw+1PszF/x9V2qx6njoaj4HvrojWdJexBPgBHYE8LEn xR+L4RlzseawKSV/IvxbNvM+4EWqT5S8gUIIQ9+DTdHLGxFQrfG7XF4rZloqcWjDU9Z9jhqxWFoQt qjO6RQQA==; 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 1fwogx-0002bO-Dn; Mon, 03 Sep 2018 13:14:55 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodO-0000pI-Gx for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:17 +0000 Received: by mail-wr1-x443.google.com with SMTP id j26-v6so639328wre.2 for ; Mon, 03 Sep 2018 06:11:04 -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=wTOILdE9nfHQCYMiecBgy4uyHPVuopq9iik1VZDg6mA=; b=ri1Dz7m59TtHxVJMvmQAzX93b2miaZDK+w8fHLMXjXDn0Hik99zFO+Rt1N2CrTGna6 /865xQZZ9F09gkGUlQcpU/UcvAJHLfFq1TlhOV3PyIcRDK6cfwn/QCMlMjva0+k+/9nu ZAYKWb4tGwymAuU+o5uljVd7gR26kM8ByJ3/o4hQTh15MfiKnl+ndP6vQoanLuuyAUvF GNKhqvZ2ZdkJ+MfZfFGF22KJp/MG5ExU7hnWSnTzFjHdzPvXOq8DMU7mBC8NBp4tMdvo LjFzdSfndYz/tDYqHLIZp7mV0MyHihfGMqx1S2zclXyIZIiJO70kH5EZzBGU//+dWTi8 vzbQ== 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=wTOILdE9nfHQCYMiecBgy4uyHPVuopq9iik1VZDg6mA=; b=s9VHb51PP9PwEdLVvIWwQ6s6TmjYLEg3HU0VPACOGjtNXsC10NxxjXzS/mLLbslQiT mPBVgToWQeBZUpcawvokVg7ttm12dKKojUT/c0Javf/GMbDqAaELqFmSkd2vnj+ZFARp 8cZyk1UQFatdFk2LgJzHJKJrhNhxxUG7zpyWxugWR2BBIWiWdhVt3lO8lbsvoU6LMQyy gklvX0ZVW6c5iQ29FLOGFkqXI4+nPNSX6wACLhrDUFF6VnBehyxEyVhaP12z+2ETOARr g7vy1X6mIqOvV32pQQBh9XGbJQYv2RjLPB4fhWzV7/LekYksolKubjuq5bzji3dpyNWC dGUQ== X-Gm-Message-State: APzg51Bl8YP547YgUhon7SbDkUYk32eGCrYOeMBeTdIBepxivwtxkewJ W1o28iCAwxpDURxTWeKtbMBVyg== X-Google-Smtp-Source: ANB0VdZZ1kcMQunUqBPmqO9KVMDszD/YeV47Dm/+4CSPjDx1Dh7tfIV5ksMIyifhfaG7vmxE9lt0Dg== X-Received: by 2002:adf:9ae5:: with SMTP id a92-v6mr20443936wrc.125.1535980263184; Mon, 03 Sep 2018 06:11:03 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id f132-v6sm11314920wme.24.2018.09.03.06.11.02 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:02 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 02/10] serial: uartps: Do not initialize field to zero again Date: Mon, 3 Sep 2018 15:10:50 +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-20180903_061114_589376_9883B37B X-CRM114-Status: GOOD ( 11.45 ) 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 Writing zero and NULLs to already initialized fields is not needed. Remove this additional writes. Signed-off-by: Michal Simek --- Changes in v3: None Changes in v2: - new patch - it can be sent separately too drivers/tty/serial/xilinx_uartps.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index dd905c981f67..9a08542cec47 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1502,15 +1502,12 @@ static int cdns_uart_probe(struct platform_device *pdev) /* 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. From patchwork Mon Sep 3 13:10:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA47D920 for ; Mon, 3 Sep 2018 13:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B81CA297C1 for ; Mon, 3 Sep 2018 13:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB027297C3; Mon, 3 Sep 2018 13:16:42 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 E995E297C1 for ; Mon, 3 Sep 2018 13:16:41 +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=zMJOIi2zxpdSbZdPMg7TMwgbVNPj2L5SapesNfBw5DM=; b=r1rvHo+2zpSmchhtnvwzfTQdO5 UCDaiGnOAYgbG/A4fq5B5WmsCMBSQSbx4IERwy9g6hSaPzSahG7eyddM25LKCpFBnHmgQ10wkWKxv PNRGnxcWjfrHVmlw71wZRuIUrkVeFBpV3yzNS/xGoVkp8/Y+Z/svcNQLW3wGp7uMpoVhEsKvPmqYE +Xz0NopKjgtUcOqu9tBmgCnkd/HZlKLDPusXFP4143tjMX2psFEhWwiWTpeE4BIsq11JNzDjv6Uuh BSjPV2ohbrZta9Pe/KauFbLOMMe0qIfrUPNWArjM7omvYEiyEv5Eo50edoq8BVyeMXJVJzq2bboa1 vY1AnaAg==; 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 1fwoiT-0004R4-Ln; Mon, 03 Sep 2018 13:16:29 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodR-0000pR-D3 for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:19 +0000 Received: by mail-wr1-x441.google.com with SMTP id a108-v6so574404wrc.13 for ; Mon, 03 Sep 2018 06:11:05 -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=y8UxnDrErzxaoHSaqXHkoDRD2bv3bmlfTzwBM+V1Aq0=; b=OAmmz4f+WbkYQ1097bi5XKeyMZ3U4MNWAR5flZRi6QKa6b1GFGn/mC5L5mbYBpoovp 38hNKlzImUmyBYwPzEm3GSTCa4fVJ2cxMAlFhqhy5eu8D224b+x20T+WfaHM3clRa7yw pTiegdFxTnacsl9CMrjsRpaGMEhG0xQt4xJ6jNV829xZkPI87Lptpu40apPSfVpU6cdo 4HTbb1WafAR+yOL0gwQfbPpCsd9PnMGg4yHXNQT669+2Vjku65tJy5Jn3RiqFAFJVsCp /EnHKEBplQwxYUxskoe2PKDNXrfxs0+7f71eR2MKJgPR2Ux4e7hBUmg+AZsaR4DgH/7L VxUw== 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=y8UxnDrErzxaoHSaqXHkoDRD2bv3bmlfTzwBM+V1Aq0=; b=L7i+FqT1oBTMiH2xXN5fynvkGUkAdmJXeEkcHmXT10x9V2DWA8bihh4uQcWl87lQB/ /KizTgHjAeMpjbtBb/ygzKTZlhVCHwVq88ghEr7ApLyJV4GbP+f3D3AB2XYQ34H6Z5E+ eKcrRG+ntMXil/qToLRinl6LsU2VzDTLR/jg4s8AJqRPcPmGBM/OTeqhn5PEtHWoEpVF pkOeYdDgsiUILAgPLHHuSL5pPB56LipsLKytJV9J9JJT9wnpgx/yhf5u7EJzenRWdKsA /HTKoYFuKqfBxH4cGwrJel4/KTL9nrnOBQYKsulsOcWB48jy6WoqBHgvfGCn7+9vySzH PzQA== X-Gm-Message-State: APzg51D45xvgEM+n3N4bD7nki00ppXXSK8OAunILm8ATIwzDJyBaiWp2 GS1x7gp12YkKg1/6wguCsJ6D1Q== X-Google-Smtp-Source: ANB0Vdazt/g3oJviGvhnyg9Tzd2SJeE/irkN8Tl+e3d4uBsSn16KK2E85oNBoRtJiI1r9bAVe4lWEg== X-Received: by 2002:adf:f045:: with SMTP id t5-v6mr19094895wro.92.1535980264715; Mon, 03 Sep 2018 06:11:04 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id m68-v6sm18555465wmb.10.2018.09.03.06.11.04 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:04 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 03/10] serial: uartps: Fix suspend functionality Date: Mon, 3 Sep 2018 15:10:51 +0200 Message-Id: <26804ea4d2196674a30ddd7dccc068269816b882.1535980253.git.michal.simek@xilinx.com> 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-20180903_061117_468508_1F6D653E X-CRM114-Status: GOOD ( 19.39 ) 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, Nava kishore Manne , Greg Kroah-Hartman , 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 From: Nava kishore Manne The driver's suspend/resume functions were buggy. If UART node contains any child node in the DT and the child is established a communication path with the parent UART. The relevant /dev/ttyPS* node will be not available for other operations. If the driver is trying to do any operations like suspend/resume without checking the tty->dev status it leads to the kernel crash/hang. This patch fix this issue by call the device_may_wake() with the generic parameter of type struct device. in the uart suspend and resume paths. It also fixes a race condition in the uart suspend path(i.e uart_suspend_port() should be called at the end of cdns_uart_suspend API this path updates the same) Signed-off-by: Nava kishore Manne Signed-off-by: Michal Simek --- Changes in v3: - New patch - can be sent separately but there is dependency that's why sent in this series Changes in v2: None drivers/tty/serial/xilinx_uartps.c | 41 +++++++++++--------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 9a08542cec47..fc0ecaf3615d 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1272,24 +1272,11 @@ static int cdns_uart_console_setup(struct console *co, char *options) static int cdns_uart_suspend(struct device *device) { struct uart_port *port = dev_get_drvdata(device); - struct tty_struct *tty; - struct device *tty_dev; - int may_wake = 0; - - /* Get the tty which could be NULL so don't assume it's valid */ - tty = tty_port_tty_get(&port->state->port); - if (tty) { - tty_dev = tty->dev; - may_wake = device_may_wakeup(tty_dev); - tty_kref_put(tty); - } + int may_wake; - /* - * Call the API provided in serial_core.c file which handles - * the suspend. - */ - uart_suspend_port(&cdns_uart_uart_driver, port); - if (!(console_suspend_enabled && !may_wake)) { + may_wake = device_may_wakeup(device); + + if (console_suspend_enabled && may_wake) { unsigned long flags = 0; spin_lock_irqsave(&port->lock, flags); @@ -1304,7 +1291,11 @@ static int cdns_uart_suspend(struct device *device) spin_unlock_irqrestore(&port->lock, flags); } - return 0; + /* + * Call the API provided in serial_core.c file which handles + * the suspend. + */ + return uart_suspend_port(&cdns_uart_uart_driver, port); } /** @@ -1318,17 +1309,9 @@ static int cdns_uart_resume(struct device *device) struct uart_port *port = dev_get_drvdata(device); unsigned long flags = 0; u32 ctrl_reg; - struct tty_struct *tty; - struct device *tty_dev; - int may_wake = 0; - - /* Get the tty which could be NULL so don't assume it's valid */ - tty = tty_port_tty_get(&port->state->port); - if (tty) { - tty_dev = tty->dev; - may_wake = device_may_wakeup(tty_dev); - tty_kref_put(tty); - } + int may_wake; + + may_wake = device_may_wakeup(device); if (console_suspend_enabled && !may_wake) { struct cdns_uart *cdns_uart = port->private_data; From patchwork Mon Sep 3 13:10:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21129112B for ; Mon, 3 Sep 2018 13:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1138E297B8 for ; Mon, 3 Sep 2018 13:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04B0D297BF; Mon, 3 Sep 2018 13:14:29 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 50610297B8 for ; Mon, 3 Sep 2018 13:14:28 +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=GRYGkSV8KAmyS0Uza8jYPHmruMOFXkT1NCNNSCPsB30=; b=kI+q0gIYIlIsPz5EhyGeJsM1MO kWjK+QUYloWVAl9v/mNeP4u55MRFWwLZv7YfOJoRB4s+KGUjrkGEq92T6NWA18nk28nhoJnwjYltA Pw2wdh1fqGrk+9XjR9zykI2Eo+fVv86gV4DFTx9A0XTn1pMEk3qyibaTd7LPPG+q0QEVAheu8UToh +K+0HwwUV16ygNCAQ451T0en8MBWsvRDvW9wiYJ7CKVm1IjDcycVCaLaiu8zGlNRxcBuC3Qz62AW5 C60FblhT3pSMkZLv5LtF/H3X9sr8Ttn3fk3gbBH2XrbmDVxS1ddy7IUNn6RrYIBYXvf8xwgaFJtt4 L3BH4pIg==; 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 1fwogH-00029W-0t; Mon, 03 Sep 2018 13:14:13 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodO-0000px-Gy for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:17 +0000 Received: by mail-wr1-x443.google.com with SMTP id 20-v6so576978wrb.12 for ; Mon, 03 Sep 2018 06:11:07 -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=xVHVmREQe1YJ/hOcPwmY7D8Tk1cvKWJ1/S6c2AWMoG4=; b=SgxAu2rVzvZ7AkcfWcyy9Og6fZgiRL1A9f+IvI9KLvTKoWKVHrF25UWkGy2DmkPD3J 5l4Maqk8jzDVMJ69Ap/GYApuq/yO5RIhfOzIVKpRFpDWAPD5Di02AInTlFRfab1QyrTK md0zZsH0tqLtTZS/8GayoM/1HIj/4V58tgfaPTcMOpHiqoMs709i5XwKDI8bgZQOtrIk CIyZEsvyneXuxlHu2K0+AF6cPLEWt8wot2qyRbGBpmILUhe0mJqIcVVzBuESv/H0ngmo b6iXCAxlnvMHOHJi9S1XE6YE2USt7hq/KES4s6ylLkeI1AwHKD85xKW3+bseLmCw0UKt KeBw== 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=xVHVmREQe1YJ/hOcPwmY7D8Tk1cvKWJ1/S6c2AWMoG4=; b=Ll1c/cUwAjDH+8ODc5EMXMSxeHI170OWlodIWngeCASAyHEp4DdL64nBO5+/tNn29G +v5agMWVK1ZVVyC3nl3NrGfjx98kFUZ+kEfQw7fx774RDwgfC9imIDe4Vc2rZiX19Cc8 qzss81gq34MTtS16FYEUCwQjj9QZPproVMXvSjY5SZmpE/IJcGP0kr0dXLKtfTRnGVVk edQG9SvhTlNgdYKDXU1JBuwMm5GSIHjoX53zOJn5yhOBjebZORTcm90HzJ+DpREKpjsW Uw1An458ZTq6D66V3kcnLsmf3E3TwcJo5rLEEWSjgOYKoyVOXtmSxfUWcRLi0FcVy61W 27tw== X-Gm-Message-State: APzg51BQsSE92H/iw37JdSL1D1YhLhCl3g+IaH9AfjJy53QES7x8vOBc H0MNgAviRyR9Z/+WjUZwwAQC6w== X-Google-Smtp-Source: ANB0VdZP1ejnhjjrmz8TAFH2GpAT5zfhBOJW3KSqNGqLz/vgKqCbfCWHJuGbz7s76u/72tI0ylWcoA== X-Received: by 2002:adf:9d81:: with SMTP id p1-v6mr18268945wre.12.1535980266368; Mon, 03 Sep 2018 06:11:06 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id b74-v6sm13926847wma.8.2018.09.03.06.11.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:05 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 04/10] serial: uartps: Do not use static struct uart_driver out of probe() Date: Mon, 3 Sep 2018 15:10:52 +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-20180903_061114_593786_7A6009F5 X-CRM114-Status: GOOD ( 15.54 ) 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 cdns_uart_suspend()/resume() and remove() are using static reference to struct uart_driver. Assign this reference to private data structure as preparation step for dynamic struct uart_driver allocation. Signed-off-by: Michal Simek --- Changes in v3: None Changes in v2: - new patch - it can be sent separately too drivers/tty/serial/xilinx_uartps.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index fc0ecaf3615d..5bd2b0607df6 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -180,6 +180,7 @@ * @port: Pointer to the UART port * @uartclk: Reference clock * @pclk: APB clock + * @cdns_uart_driver: Pointer to UART driver * @baud: Current baud rate * @clk_rate_change_nb: Notifier block for clock changes * @quirks: Flags for RXBS support. @@ -188,6 +189,7 @@ struct cdns_uart { struct uart_port *port; struct clk *uartclk; struct clk *pclk; + struct uart_driver *cdns_uart_driver; unsigned int baud; struct notifier_block clk_rate_change_nb; u32 quirks; @@ -1272,6 +1274,7 @@ static int cdns_uart_console_setup(struct console *co, char *options) static int cdns_uart_suspend(struct device *device) { struct uart_port *port = dev_get_drvdata(device); + struct cdns_uart *cdns_uart = port->private_data; int may_wake; may_wake = device_may_wakeup(device); @@ -1295,7 +1298,7 @@ static int cdns_uart_suspend(struct device *device) * Call the API provided in serial_core.c file which handles * the suspend. */ - return uart_suspend_port(&cdns_uart_uart_driver, port); + return uart_suspend_port(cdns_uart->cdns_uart_driver, port); } /** @@ -1307,6 +1310,7 @@ static int cdns_uart_suspend(struct device *device) static int cdns_uart_resume(struct device *device) { struct uart_port *port = dev_get_drvdata(device); + struct cdns_uart *cdns_uart = port->private_data; unsigned long flags = 0; u32 ctrl_reg; int may_wake; @@ -1314,8 +1318,6 @@ static int cdns_uart_resume(struct device *device) may_wake = device_may_wakeup(device); if (console_suspend_enabled && !may_wake) { - struct cdns_uart *cdns_uart = port->private_data; - clk_enable(cdns_uart->pclk); clk_enable(cdns_uart->uartclk); @@ -1349,7 +1351,7 @@ static int cdns_uart_resume(struct device *device) spin_unlock_irqrestore(&port->lock, flags); } - return uart_resume_port(&cdns_uart_uart_driver, port); + return uart_resume_port(cdns_uart->cdns_uart_driver, port); } #endif /* ! CONFIG_PM_SLEEP */ static int __maybe_unused cdns_runtime_suspend(struct device *dev) @@ -1413,6 +1415,8 @@ static int cdns_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver; + match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); if (match && match->data) { const struct cdns_platform_data *data = match->data; @@ -1570,7 +1574,7 @@ static int cdns_uart_remove(struct platform_device *pdev) clk_notifier_unregister(cdns_uart_data->uartclk, &cdns_uart_data->clk_rate_change_nb); #endif - rc = uart_remove_one_port(&cdns_uart_uart_driver, port); + rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port); port->mapbase = 0; clk_disable_unprepare(cdns_uart_data->uartclk); clk_disable_unprepare(cdns_uart_data->pclk); From patchwork Mon Sep 3 13:10:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB18F112B for ; Mon, 3 Sep 2018 13:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C92982942D for ; Mon, 3 Sep 2018 13:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD54C29796; Mon, 3 Sep 2018 13:12: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,RCVD_IN_DNSWL_NONE autolearn=ham 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 2410C2942D for ; Mon, 3 Sep 2018 13:12: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=YOTy918LP8YeWMGOoZzGhPCC5/NcIYHAcC+ALycxhIs=; b=L/FPABOkR+hgnzxlRutAXi3E01 I9q1AkZJ//gykBLIH3c8WP4/6nuHfM/PXAJ82uoLt93TpxUqNAgcCvP7b6wFYrRKE/XzYVkfps3nu 0toWZnC1gmgXrqXrc8nSEumdxbmfvlQHwJUlobpbsElSKMDvaaZCmu++wlQe+V9tcTn44nJznDpDK 5lES95vvvR6UZ/fQnJ+9sE/tJdG7bh89zzhbius/5UEDyflReHwZIPLfXlhNhWJ7bdT+9Gb079Dfv gEQuqEIWaD5r+7RkqBfOzkC/Hid6HVo1WwW2RWxOQwJt8XbnYm8w9Un5plAimOAsW/38wgzAXGXP6 2Ke4jEcA==; 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 1fwody-00018c-P0; Mon, 03 Sep 2018 13:11:50 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodN-0000qU-4M for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:15 +0000 Received: by mail-wr1-x442.google.com with SMTP id a108-v6so574552wrc.13 for ; Mon, 03 Sep 2018 06:11:08 -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=28aWEqk5ccUrLG2mIr/fR9GT68w8zaKxoQ9DZA4uMA8=; b=Xs8AVDnn2wmLxjJn/4jfdLQJNXTmnddB0Zqzcy9jcNvnJTTY+xPtDFNWkAN85+ScGm mygipDP2bHfDY9pF/vQPiA1gZny2U2E5Mbx9FTSG2v+gIgqDidOOVGraIoK92v71b4hO U4ZOv9wQbGY4hPsbD1/e15wAd183Tyhj4zvc1O5kg72x4qUAWmBe4uJfrJCTQLor9tCT 89NFkQRq1nUo2wv3x2Nd7Jr8A+4hrehXhtQMog5sOZO/4PlkArF2jVhZ1Y6xt6vTj8BD AKHfP+XxF585ijhqt31S7M5uNJVIrSlXV3gJlHuyZ9G+2/DY4PczWa7YCq+WGigdFfn0 tkPQ== 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=28aWEqk5ccUrLG2mIr/fR9GT68w8zaKxoQ9DZA4uMA8=; b=S0VAZo89QkqftBkVIxFKsa6kV+mYiLdDRtdJWHttu6qbmrAh7IZvU0y2KdxEJNeIr8 I6lBjiHcnxA57RqXT9Ch0fFgRVk7b9IDXTAzVJRPEz319ovhr+ZfVHdAy6gRKYAFZ8Ii BvF2nPyvUX/4AwKfe2C4XPYClPApkzPDCHXMrwuBG7FfjB/10Z1nWVQH7Duz41h0Mm0a gJwa3/dH7/jvC9ZTp46WGkvYbfJYm5vSUYEYlVkVvFaFLE0rxbjwPPHFEb5yII/oW+qf c4GR9lVogMPsx3Gz0iXpfsvPIwGJjE1K2dIBXm+JekkslpRnMF4kQDf97cj0fcCiftUy PXPA== X-Gm-Message-State: APzg51CoCS+/PMifQ6VO4u3+Mbfx2MptyoP6TU9E2iDGq6h57hqFQzIn 8bpuBAfxFU9aJ01jlB6UUoJgzQ== X-Google-Smtp-Source: ANB0VdYH8gASwdpILad2XoC9CvzoT+vRDN9qm8X3G33eUwmt8HH1qqqZAxS/f01Y0dy+XtqdDR2bKA== X-Received: by 2002:adf:e6c2:: with SMTP id y2-v6mr19268788wrm.35.1535980267815; Mon, 03 Sep 2018 06:11:07 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id v1-v6sm13362609wrt.34.2018.09.03.06.11.07 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:07 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 05/10] serial: uartps: Move alias reading higher in probe() Date: Mon, 3 Sep 2018 15:10:53 +0200 Message-Id: <56adfce565f2d743d21d80533ce20218514c7466.1535980253.git.michal.simek@xilinx.com> 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-20180903_061113_212293_DC45F95B X-CRM114-Status: GOOD ( 14.85 ) 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 This cosmetic change is done only for having next patch much easier to read. Moving id setup higher in probe is not affecting any usage of this driver and it also simplify error path. Signed-off-by: Michal Simek --- Changes in v3: None Changes in v2: - new patch - it can be sent separately too drivers/tty/serial/xilinx_uartps.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 5bd2b0607df6..a3e97ccb376d 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1415,6 +1415,16 @@ static int cdns_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + /* Look for a serialN alias */ + id = of_alias_get_id(pdev->dev.of_node, "serial"); + if (id < 0) + id = 0; + + if (id >= CDNS_UART_NR_PORTS) { + dev_err(&pdev->dev, "Cannot get uart_port structure\n"); + return -ENODEV; + } + cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver; match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); @@ -1476,16 +1486,6 @@ static int cdns_uart_probe(struct platform_device *pdev) &cdns_uart_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; - - if (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); @@ -1544,7 +1544,6 @@ static int cdns_uart_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); -err_out_notif_unreg: #ifdef CONFIG_COMMON_CLK clk_notifier_unregister(cdns_uart_data->uartclk, &cdns_uart_data->clk_rate_change_nb); From patchwork Mon Sep 3 13:10:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A89314BD for ; Mon, 3 Sep 2018 13:16:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79627297B8 for ; Mon, 3 Sep 2018 13:16:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C1F1297C5; Mon, 3 Sep 2018 13:16:00 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 D3706297B8 for ; Mon, 3 Sep 2018 13:15:59 +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=G/0phdVFvShBkAtXw+eLTaAMee4tG+XaGRg35hndH/g=; b=Pn3QCRxETcipN5qTAAD2oLdwoa NNiUZyMObVMEcBZNCTzwHSQzCiBqYlQqSpBafKBTGQjG1QT5hRkplzMcKc+pyI+BlnMjdwJSLZKP+ +0cy1UhEbnpBItng5dV6QLOymjaN9DMGkaKiEMcSRNW//47PhIvjEf/UY6QpX5vMWEoizE/Aapqzl qAUyetdjr/eKPHs0ykzJPobBKok1NGnHWot4TMqXQbvQ8rZvr/qCd3kIDUrSKDs8t+LvYCZG/08Jq yirYEHN5VtNaqZnObMI47SQbdo2ql+bfzMMWo32qrMGuGc9all06ceIytgMr8O2mSTOwEhrVTue80 3DopCbrQ==; 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 1fwohl-00049R-HF; Mon, 03 Sep 2018 13:15:45 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodN-0000qW-4S for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:18 +0000 Received: by mail-wr1-x442.google.com with SMTP id k5-v6so592030wre.10 for ; Mon, 03 Sep 2018 06:11: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=vUJIU/oycKpUavEMI7cnrlQPvFWatIHlTatXEyH0+aA=; b=FNGFIMLGXYRRLPxW41klBDDgvWIpWQ8Wp7GL5yc6hCPIO1zZTwuWpjgLocWGqc6gBI i1H6T9fOwbe5zTOnBun/oCE+QHZnrsipyGZFEps42vzV9HPPAXfzGD7OaSXNbHnjjkRY oj/vHRpTBZfEH0ACGk8+0J1FQePnXRt7vduRdKgWssLQet6ZxbSWk/X89AwE7vksrj3K zxpfUUlbMvsIAPdzUgn4TcQI661kBQqOlft5xWZqR/gDASBtSK8HEfJJuPo0MOfSK73y daZhBZznpq3WBIMhRWXdKqJ4r4BUPizruj3CfzDxmLIVIZAy90Jey0RUuW1KPA2U7T0w gYSg== 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=vUJIU/oycKpUavEMI7cnrlQPvFWatIHlTatXEyH0+aA=; b=Xu1RbeyUFeVJv0KKGb0a13FfYkJ4Voo/6CJmAAZVeDgc6IN4rqw3f4duhodRlWQl8u tkk+hNqtd3EZN7yQtQ4un2gCF7sKOpHGP96lUmmvukULffq0GuhSgqZlAXbLZu6oN3fN wcROvS+/FCbFnzHCyYCKwNuOZ1i6cjId8yXkfajpF1B+w32EZgTKPEffBeCtJisFxxpi KonRM6YB9jxNFgMwq+iOdcRH95wLWEOuRApud5zKdmxj8ghQn7MpIDgxYVBj4OafkZWl fhduVJW54lNLogr+It+TYqy+Q7W33i2eQXLn1mgtYAArYWY0MHVwcsjXyx676tPL96yo 5Zlg== X-Gm-Message-State: APzg51BAlIcpw3HfGY7jBpOv4Sz+zXon4HJlI1pe+6j+UFyf2j78Gn5B jnujQAMysAcssI6UMPfeIZmWaQ== X-Google-Smtp-Source: ANB0VdaM9wEPe/dEsMlVEhEfZfmqV+9pmkc3Cr6k5PHmhjoubjzW5lPIFZF70EbOXl3pwfYvB9HGeA== X-Received: by 2002:a5d:4648:: with SMTP id j8-v6mr18447306wrs.52.1535980269278; Mon, 03 Sep 2018 06:11:09 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id v16-v6sm14975923wrw.12.2018.09.03.06.11.08 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:08 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 06/10] serial: uartps: Move register to probe based on run time detection Date: Mon, 3 Sep 2018 15:10:54 +0200 Message-Id: <0ffd804b18c15b60a64aecadcf32b0036e6cbcdb.1535980253.git.michal.simek@xilinx.com> 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-20180903_061113_217490_0655E4C5 X-CRM114-Status: GOOD ( 17.99 ) 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 Register uart driver in probe to be able to register one device with unique major/minor separately. Also calculate number of instances of this driver to be able to call uart_unregister_driver() when there is no instance. Signed-off-by: Michal Simek --- Changes in v3: - Fix uart_unregister_driver() in error path or when driver is removed. - Change commit message Changes in v2: - Remove nr field logic Discussed here: https://patchwork.kernel.org/patch/9738445/ The same solution is done in pl011 driver. --- drivers/tty/serial/xilinx_uartps.c | 42 +++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index a3e97ccb376d..54735a7f9960 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1393,6 +1393,9 @@ static int __maybe_unused cdns_runtime_resume(struct device *dev) }; MODULE_DEVICE_TABLE(of, cdns_uart_of_match); +/* Temporary variable for storing number of instances */ +static int instances; + /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1425,6 +1428,14 @@ static int cdns_uart_probe(struct platform_device *pdev) return -ENODEV; } + if (!cdns_uart_uart_driver.state) { + rc = uart_register_driver(&cdns_uart_uart_driver); + if (rc < 0) { + dev_err(&pdev->dev, "Failed to register driver\n"); + return rc; + } + } + cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver; match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); @@ -1442,7 +1453,8 @@ static int cdns_uart_probe(struct platform_device *pdev) } if (IS_ERR(cdns_uart_data->pclk)) { dev_err(&pdev->dev, "pclk clock not found.\n"); - return PTR_ERR(cdns_uart_data->pclk); + rc = PTR_ERR(cdns_uart_data->pclk); + goto err_out_unregister_driver; } cdns_uart_data->uartclk = devm_clk_get(&pdev->dev, "uart_clk"); @@ -1453,13 +1465,14 @@ static int cdns_uart_probe(struct platform_device *pdev) } if (IS_ERR(cdns_uart_data->uartclk)) { dev_err(&pdev->dev, "uart_clk clock not found.\n"); - return PTR_ERR(cdns_uart_data->uartclk); + rc = PTR_ERR(cdns_uart_data->uartclk); + goto err_out_unregister_driver; } rc = clk_prepare_enable(cdns_uart_data->pclk); if (rc) { dev_err(&pdev->dev, "Unable to enable pclk clock.\n"); - return rc; + goto err_out_unregister_driver; } rc = clk_prepare_enable(cdns_uart_data->uartclk); if (rc) { @@ -1538,6 +1551,7 @@ static int cdns_uart_probe(struct platform_device *pdev) console_port = NULL; #endif + instances++; return 0; err_out_pm_disable: @@ -1552,7 +1566,9 @@ static int cdns_uart_probe(struct platform_device *pdev) clk_disable_unprepare(cdns_uart_data->uartclk); err_out_clk_dis_pclk: clk_disable_unprepare(cdns_uart_data->pclk); - +err_out_unregister_driver: + if (!instances) + uart_unregister_driver(cdns_uart_data->cdns_uart_driver); return rc; } @@ -1580,6 +1596,8 @@ static int cdns_uart_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); + if (!--instances) + uart_unregister_driver(cdns_uart_data->cdns_uart_driver); return rc; } @@ -1595,28 +1613,14 @@ static int cdns_uart_remove(struct platform_device *pdev) static int __init cdns_uart_init(void) { - int retval = 0; - - /* Register the cdns_uart driver with the serial core */ - retval = uart_register_driver(&cdns_uart_uart_driver); - if (retval) - return retval; - /* Register the platform driver */ - retval = platform_driver_register(&cdns_uart_platform_driver); - if (retval) - uart_unregister_driver(&cdns_uart_uart_driver); - - return retval; + return platform_driver_register(&cdns_uart_platform_driver); } static void __exit cdns_uart_exit(void) { /* Unregister the platform driver */ platform_driver_unregister(&cdns_uart_platform_driver); - - /* Unregister the cdns_uart driver */ - uart_unregister_driver(&cdns_uart_uart_driver); } arch_initcall(cdns_uart_init); From patchwork Mon Sep 3 13:10:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2729139B for ; Mon, 3 Sep 2018 13:13:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1031297A5 for ; Mon, 3 Sep 2018 13:13:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A50E1297B3; Mon, 3 Sep 2018 13:13:40 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 EBF68297A5 for ; Mon, 3 Sep 2018 13:13:39 +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=/9MZ9Ec1sIiZIgTkU2aj7UDFGJJvOorf7w1j9yQC4uM=; b=sAmoUZVeEO7s338/HFyaVr+//P yQaQV24mhJFyDJ1xCYFAGKBSzjyQvO9icuB1K4ba4VENPo0nvl9pBzj61YHHLJoxfN484wqicQDtq zhFP25AA63davnYXgYK1gTGJbK4nmJ5ZBCmD5Abp7OYc68aDpurYdoBBXHqbeRKfQNN2eUChr+uUB dt3HWsOgjcZHEV2dAInuqCaMR5Qvus7aXXKhAmk3E5KDmsfKLNbRf+3iwYbPOXdVG3ayP6oO6+7gi fp+OH0vmylUagedNLIq1ruHFWoGlITrVtNGq5oqqD8HERabRlprz8z6CMysJwzDHTEg2KH872H6Gn L55YBpnw==; 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 1fwofa-0001tG-9L; Mon, 03 Sep 2018 13:13:30 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodN-0000qa-G3 for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:17 +0000 Received: by mail-wm0-x241.google.com with SMTP id 207-v6so1088522wme.5 for ; Mon, 03 Sep 2018 06:11:11 -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=bs9NcxnSSv/Ae7hcuKd4ij0d/Px3jNTx8MFPf905skA=; b=P35ow6rB9nb+ALt/PVEJ2Sx/qex/vJsufG8LQll3mBRs/AKIrvi9f6zQmcimn1yGuu nK8TQd5BNvXLnj1JxvLvtoUii87fzBTmxHaysUZj6iY/4tmNcmlX2dPfK3lp9aUHerZd Vk2zAJYmX5iLYAAet4qw4kobVZgUq/iTJIdOoVd9f2ZjO8jHmNiOVBEQb8yVbhGIzAw/ ghTsew/06CGgRuKR/caySeAL9wYYnPQju6xi4NCDGi4KAOvjGZ5lSlXi8OXwG7Zh4W08 cQySlCz603keM46aNv7kWNSMaQqMXsPdz7VW5yFdL9+2+SxdEqnCiuEL6qswLjwp8Kac 7vuw== 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=bs9NcxnSSv/Ae7hcuKd4ij0d/Px3jNTx8MFPf905skA=; b=sD1ghUUzZjd5QZs8KP2r/FRWnNoL4qXoWQ+qilNf1PxUTZ2XQxZsfxww6BJLNT2OvO 4AD86Y/UXB3py9vaz39uw5QB8M1Tx4DvOQaEwmZtMPPzOKmHxgA73L2AOtUi+H28BYS3 Cnl+gWi06myxErPa8X/8YjgobtVtPLXbU/oLSYphazpBRZvZaysXZgROwY9Y9Z8aPri5 JbvpcZPLReghMAOM8Pprbu0hudj1pwSLXDXLZwrqe2JjZTwmbQDdQl40k2kONpjI+z9U hbr3VUuGz8XYsCXPmGW2LspduGtJmQcH5sFVieZuCQnVPhQs6xP181+y2C1+4NL4rl8X hUJw== X-Gm-Message-State: APzg51Aw6bejDvZmIOGck+g4/hM7iOT5ACQoZkH7GtjmQiNr5CULdyzz cH9FBWVp5ZDCNiQHwhdYlwAuUA== X-Google-Smtp-Source: ANB0VdaDP9KScgwZbHeX5mFwsvXi/X9akGQqFAqG4Btknl/lKOnWKKrQ0dQ62LILo5lFmTeS+3gQZw== X-Received: by 2002:a1c:398b:: with SMTP id g133-v6mr4880491wma.5.1535980270735; Mon, 03 Sep 2018 06:11:10 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id h17-v6sm17050587wrq.73.2018.09.03.06.11.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:10 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 07/10] serial: uartps: Fill struct uart_driver in probe() Date: Mon, 3 Sep 2018 15:10:55 +0200 Message-Id: <9a2f438e7d7e39b1ce965d09cebd9fb799422479.1535980253.git.michal.simek@xilinx.com> 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-20180903_061113_579239_9912AB51 X-CRM114-Status: GOOD ( 13.35 ) 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 This is preparation step for dynamic port allocation without CDNS_UART_NR_PORTS macro. Fill the structure only once at probe. Signed-off-by: Michal Simek --- Changes in v3: - s/,/;/ in filling structure - get cdns_uart_uart_driver out of PS_UART_CONSOLE ifdefs Changes in v2: - new patch - it can be sent separately too drivers/tty/serial/xilinx_uartps.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 54735a7f9960..61087233f411 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1099,6 +1099,8 @@ static void cdns_uart_pm(struct uart_port *port, unsigned int state, #endif }; +static struct uart_driver cdns_uart_uart_driver; + #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /** * cdns_uart_console_putchar - write the character to the FIFO buffer @@ -1239,8 +1241,6 @@ static int cdns_uart_console_setup(struct console *co, char *options) return uart_set_options(port, co, baud, parity, bits, flow); } -static struct uart_driver cdns_uart_uart_driver; - static struct console cdns_uart_console = { .name = CDNS_UART_TTY_NAME, .write = cdns_uart_console_write, @@ -1252,18 +1252,6 @@ static int cdns_uart_console_setup(struct console *co, char *options) }; #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ -static struct uart_driver cdns_uart_uart_driver = { - .owner = THIS_MODULE, - .driver_name = CDNS_UART_NAME, - .dev_name = CDNS_UART_TTY_NAME, - .major = CDNS_UART_MAJOR, - .minor = CDNS_UART_MINOR, - .nr = CDNS_UART_NR_PORTS, -#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE - .cons = &cdns_uart_console, -#endif -}; - #ifdef CONFIG_PM_SLEEP /** * cdns_uart_suspend - suspend event @@ -1429,6 +1417,16 @@ static int cdns_uart_probe(struct platform_device *pdev) } if (!cdns_uart_uart_driver.state) { + cdns_uart_uart_driver.owner = THIS_MODULE; + cdns_uart_uart_driver.driver_name = CDNS_UART_NAME; + cdns_uart_uart_driver.dev_name = CDNS_UART_TTY_NAME; + cdns_uart_uart_driver.major = CDNS_UART_MAJOR; + cdns_uart_uart_driver.minor = CDNS_UART_MINOR; + cdns_uart_uart_driver.nr = CDNS_UART_NR_PORTS; +#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE + cdns_uart_uart_driver.cons = &cdns_uart_console; +#endif + rc = uart_register_driver(&cdns_uart_uart_driver); if (rc < 0) { dev_err(&pdev->dev, "Failed to register driver\n"); From patchwork Mon Sep 3 13:10:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B0C613BB for ; Mon, 3 Sep 2018 13:19:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4EC2978E for ; Mon, 3 Sep 2018 13:19:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F62129796; Mon, 3 Sep 2018 13:19:11 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 EAD342978E for ; Mon, 3 Sep 2018 13:19:10 +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=rSFcPRaWeuDMCw61I5fFcPiaNKZvqpPfEFlGOjfE0qQ=; b=tN+DAa0s48LcOM+kIkxYzXDMlK 4L63tVESw4loEy6WCaapW/hs+P2fDfYB6zDZBV7LowgfU1T7uf0kHphLkodZ2156oxcFKDvTxnBw+ d/AhNAMTOQWNr0JhqPILFGYbJuiB2QnIJNS5gW5+VP16NFCAoSaL9rCseIDqhFftMr6xzDw9WvVsu 5gpKWQuVXUODxE/p9NnPfjOqtMn8cYsZaFr0LQA0TTTjlZwIJGneJEAg2rbdsQZh0q5nekRWWpqn8 uQXihg+Cy64cP3y62hB4Q5uLgHne9uq+6Nic/ARWIqA5tuIgiK6/8sAHczwcRm2+njnhPxmD0yNWa 9MEOgVCA==; 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 1fwoks-0005Np-AZ; Mon, 03 Sep 2018 13:18:58 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodX-0000qx-Hg for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:27 +0000 Received: by mail-wr1-x442.google.com with SMTP id g33-v6so651534wrd.1 for ; Mon, 03 Sep 2018 06:11:13 -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=IEO3yDjZVgWsh5LL+iyO+h5Gjo8oaKkP6OuPubrdvDI=; b=b72F7YunxZp9VNZw+vhHRA8VxNTCZPReawxwFsgS9Bq6RPbNclo8PlROsNU2UPJqqu ttQ6/qApGaBtl0tzUNLOdjphjhM+B5KAfJtABQDLcrdbx86uZ4NKK7o2SENmb3sKzmDA dBtpVB8I6+kH4p15MpQxl/yGbxHL3oLdeCfpHGFJNSiSFQ2B//Nu2kBSrQjYEBctaIJP bOeHMqautuMHOATUxxRAK+SfuQFknzCwX5rbsy3YNittc5sVNIn4rOcAaU9Cc+hsiUax jXK5HC3R5OYWf9rGG5fJOX8w8TJ3LDSrOP+gXht43hpGwYsoyj5BgN7aG8+Uef55v77M 1xUg== 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=IEO3yDjZVgWsh5LL+iyO+h5Gjo8oaKkP6OuPubrdvDI=; b=E2+OHeSHJgksDmG4hzOKhS/4qOnJyhpqPbu3UhBIPkPUSm+4YZ4VZo5tvE43Qo6tNO 8YpUOQu5jvtt6qhKwcE4A/+TskDPYuT7NmABggEwaRNzwN1enpvpBYv9Lokq1jBDRxNb tUX/MbR2Tg1TN24zqVhoSD0RLoM3iBJz1qe4ekBhmTD6rG9al/5J5x7JS7vKWd2Hu53V lix4Q9xvYKinMCzvoVWhP9dovIHC5MYR157oZ2uBcGuYgOpnoL18cfTJtRed/WFt3OFf MlFBpx4hWZtCZA4eY8s2rFC0sEc4nrApKQTR83a8ZGBO98W3v9QLUxl3RM1Keea3bnPz O+Ww== X-Gm-Message-State: APzg51A5cxzbOxc1NTf8LHP1VmFLC9r+90rvl4FA3sWx8SeRvhV5bYCa QPqUfy1TWTGq2q4zaAtDZ7/ddA== X-Google-Smtp-Source: ANB0VdbbRRV10cJTTFfrFnlVyqpux9vntv7MLfprlRri607PCLGe3WZMv0H7dD3ZDexxpWKF4oMtgg== X-Received: by 2002:adf:fc83:: with SMTP id g3-v6mr19105157wrr.216.1535980272205; Mon, 03 Sep 2018 06:11:12 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id e14-v6sm12245995wrv.44.2018.09.03.06.11.11 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:11 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 08/10] serial: uartps: Change logic how console_port is setup Date: Mon, 3 Sep 2018 15:10:56 +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-20180903_061123_715138_45943E2E X-CRM114-Status: GOOD ( 13.87 ) 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 Change logic how console_port is setup by using CON_ENABLED flag instead of index. There will be unique cdns_uart_console() structures that's why code can't use id for console_port assignment. Signed-off-by: Michal Simek --- Changes in v3: - New patch in series Changes in v2: None drivers/tty/serial/xilinx_uartps.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 61087233f411..0e578c0a8ce0 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1532,7 +1532,7 @@ static int cdns_uart_probe(struct platform_device *pdev) * If register_console() don't assign value, then console_port pointer * is cleanup. */ - if (cdns_uart_uart_driver.cons->index == -1) + if (!console_port) console_port = port; #endif @@ -1545,7 +1545,8 @@ static int cdns_uart_probe(struct platform_device *pdev) #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /* This is not port which is used for console that's why clean it up */ - if (cdns_uart_uart_driver.cons->index == -1) + if (console_port == port && + !(cdns_uart_uart_driver.cons->flags & CON_ENABLED)) console_port = NULL; #endif @@ -1594,6 +1595,12 @@ static int cdns_uart_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); + +#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE + if (console_port == port) + console_port = NULL; +#endif + if (!--instances) uart_unregister_driver(cdns_uart_data->cdns_uart_driver); return rc; From patchwork Mon Sep 3 13:10:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89C21175A for ; Mon, 3 Sep 2018 13:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B37C293A6 for ; Mon, 3 Sep 2018 13:18:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EC0C293AD; Mon, 3 Sep 2018 13:18:17 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 82A72293A6 for ; Mon, 3 Sep 2018 13:18:16 +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=uprNmlifbd/DGa66NwM8cI3xPL6JKhqYq039l2DxhCs=; b=AD/wvFM3v9NS5b5CsIze6TlYlu yCkVCph458rTit8joG2M2Ib9TDECcMfYTQ+nvHa3k7TpN1Xe3l8FQ9bC2gDF8jCavzKMsR235aRNH +a8FGIGMe33HLRV22jfd59Uzmuk/p4MWoaBZXtswhg6kYYq/kmEkc1aSIQ4i0nhxqdpw2y1BkBE/y NfIhalb+GSbuYDYnXuI8+KYDBKM2EEDrGAq1MBtt/k4A6sO+xs4g1wx/FaUikZYfnlxKngrJoOW81 IZU/gGNHK7jHWTxQSCQ7B5b1AieqY84cq9VILcISNuOqyUE0jWJAp8pMvByMiVT7QxE4P9qLbP0Uk qIMzr2kA==; 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 1fwok0-00052W-T3; Mon, 03 Sep 2018 13:18:05 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodX-0000sh-H0 for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:26 +0000 Received: by mail-wr1-x442.google.com with SMTP id 20-v6so577379wrb.12 for ; Mon, 03 Sep 2018 06:11:14 -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=AJ4hoDvE5FWCI2mPaNOE8qnyRjQKP5cSjCuONyU3Hbo=; b=VA6sda/s4G0npzXTxDdHUyYsw1sUGR6Tu+mefmAScnJ6uPz2jb0rWCirJze8YTpzwS igORmiZET4Ukppg+zbZkXZ/yWy9E769uBX+gnrVe3KnAa75Is3JExor699i0ncHdWSBR PaYR1IQkAyZJtldD8MYjeH/QlbiV72IhnwB3xbFOgCqWJew1Oypm4AImpT1z0CfI50Ea j+FRREgsaxON9/VZgS/xlIb9TSXypURlQWgqz/WwFxE1Ehtz1ZvYNRGcZsM0B9xeJgBN tDlp6xXsJUn/o4wU8B+gBzW/l+sLe0bVdrj9ulLa/1/b+g/MzFvOTHeN0O3Vd8r90xbW Q1/g== 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=AJ4hoDvE5FWCI2mPaNOE8qnyRjQKP5cSjCuONyU3Hbo=; b=btC21rCBs2IGfLlkXP6jQz6UrS5IGtu6pOrSYhscVXlH19HwC1I/KP4qolJ1IU8Zsc gNrPfugJqb9YzrKl+slqaOlEIWfZLj5T3PuXixprXagody0vNYejIpWwVx4Uk/SyD/DA A9qU23OJQ5CZtNST6APW94fyEZVN9G8FYYTJKdNLpGTxAFGz9mHNM5HMXQIAzh+qoURj WExoV90kDrkpCVxeKYOxd5WqCKOyPFcYtYDQe9diBFQmZB92Z0KJGBSVcl5ecUmU1xKu YoirCRkwd3CxuJK/BlLk9OeWJuLiXjhHP1lnXmGg1Y6EFxLaP3Ckl/pijmgV9Jp3vyIz lAPg== X-Gm-Message-State: APzg51CJg+5U7lHCGA4PMZ4XISkFIisiH6/h1f+kRfOKf8ol/0rwp0Pa LoYPYEeLgl4lu8/L1QdD3i1NAA== X-Google-Smtp-Source: ANB0VdYiRs83FvbR+8oPYqEjwaDvorAGydBOrjo/S+s4V2wMtfsUNq6Ofy4ZP3j5GDqpLOaykUfz6Q== X-Received: by 2002:adf:e991:: with SMTP id h17-v6mr19887379wrm.238.1535980273738; Mon, 03 Sep 2018 06:11:13 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id f6-v6sm18646920wrr.68.2018.09.03.06.11.12 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:13 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 09/10] serial: uartps: Register own uart console and driver structures Date: Mon, 3 Sep 2018 15:10:57 +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-20180903_061123_609374_A4C5A215 X-CRM114-Status: GOOD ( 24.57 ) 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 Every instance is registering own struct console and struct uart_driver with minor number which corresponds to alias ID (or 0 now) and with 1 uart port. The same alias ID is saved to tty_driver->name_base which is key field for creating ttyPSX name. Because name_base and minor number are setup already there is no need to setup any port->line number because 0 is the right value. Unfortunately this driver is setting up major number to 0 for using dynamic assignment and kernel is allocating different major numbers for every instance instead of using the same major and different minor number. ~# ls -la /dev/ttyPS* crw------- 1 root root 252, 0 Jan 1 03:36 /dev/ttyPS0 crw--w---- 1 root root 253, 1 Jan 1 00:00 /dev/ttyPS1 When major number is not 0. For example 252 then major/minor combinations are in expected form ~# ls -la /dev/ttyPS* crw------- 1 root root 252, 0 Jan 1 04:04 /dev/ttyPS0 crw--w---- 1 root root 252, 1 Jan 1 00:00 /dev/ttyPS1 Driver is not freeing struct cdns_uart_console in case that instance is not used as console. The reason is that console is incorrectly unregistred and "console [0] disabled" message will be shown. Signed-off-by: Michal Simek --- Changes in v3: - Rebase on the top of previous broken patch - Change patch subject ("was serial: uartps: Remove CDNS_UART_NR_PORTS macro") - Keep CDNS_UART_NR_PORTS in this patch and remove it in next one and align commit message to reflect this - Allocate struct console dynamically too to be unique for every instance - Cleanup error path Changes in v2: - Register one uart_driver with unique minor at probe time --- drivers/tty/serial/xilinx_uartps.c | 93 ++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index 0e578c0a8ce0..d838612eda6f 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -30,7 +30,6 @@ #define CDNS_UART_TTY_NAME "ttyPS" #define CDNS_UART_NAME "xuartps" #define CDNS_UART_MAJOR 0 /* use dynamic node allocation */ -#define CDNS_UART_MINOR 0 /* works best with devtmpfs */ #define CDNS_UART_NR_PORTS 2 #define CDNS_UART_FIFO_SIZE 64 /* FIFO size */ #define CDNS_UART_REGISTER_SPACE 0x1000 @@ -1099,8 +1098,6 @@ static void cdns_uart_pm(struct uart_port *port, unsigned int state, #endif }; -static struct uart_driver cdns_uart_uart_driver; - #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /** * cdns_uart_console_putchar - write the character to the FIFO buffer @@ -1240,16 +1237,6 @@ static int cdns_uart_console_setup(struct console *co, char *options) return uart_set_options(port, co, baud, parity, bits, flow); } - -static struct console cdns_uart_console = { - .name = CDNS_UART_TTY_NAME, - .write = cdns_uart_console_write, - .device = uart_console_device, - .setup = cdns_uart_console_setup, - .flags = CON_PRINTBUFFER, - .index = -1, /* Specified on the cmdline (e.g. console=ttyPS ) */ - .data = &cdns_uart_uart_driver, -}; #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ #ifdef CONFIG_PM_SLEEP @@ -1381,9 +1368,6 @@ static int __maybe_unused cdns_runtime_resume(struct device *dev) }; MODULE_DEVICE_TABLE(of, cdns_uart_of_match); -/* Temporary variable for storing number of instances */ -static int instances; - /** * cdns_uart_probe - Platform driver probe * @pdev: Pointer to the platform device structure @@ -1397,6 +1381,11 @@ static int cdns_uart_probe(struct platform_device *pdev) struct resource *res; struct cdns_uart *cdns_uart_data; const struct of_device_id *match; + struct uart_driver *cdns_uart_uart_driver; + char *driver_name; +#ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE + struct console *cdns_uart_console; +#endif cdns_uart_data = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data), GFP_KERNEL); @@ -1406,6 +1395,12 @@ static int cdns_uart_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + cdns_uart_uart_driver = devm_kzalloc(&pdev->dev, + sizeof(*cdns_uart_uart_driver), + GFP_KERNEL); + if (!cdns_uart_uart_driver) + return -ENOMEM; + /* Look for a serialN alias */ id = of_alias_get_id(pdev->dev.of_node, "serial"); if (id < 0) @@ -1416,25 +1411,50 @@ static int cdns_uart_probe(struct platform_device *pdev) return -ENODEV; } - if (!cdns_uart_uart_driver.state) { - cdns_uart_uart_driver.owner = THIS_MODULE; - cdns_uart_uart_driver.driver_name = CDNS_UART_NAME; - cdns_uart_uart_driver.dev_name = CDNS_UART_TTY_NAME; - cdns_uart_uart_driver.major = CDNS_UART_MAJOR; - cdns_uart_uart_driver.minor = CDNS_UART_MINOR; - cdns_uart_uart_driver.nr = CDNS_UART_NR_PORTS; + /* There is a need to use unique driver name */ + driver_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%d", + CDNS_UART_NAME, id); + if (!driver_name) + return -ENOMEM; + + cdns_uart_uart_driver->owner = THIS_MODULE; + cdns_uart_uart_driver->driver_name = driver_name; + cdns_uart_uart_driver->dev_name = CDNS_UART_TTY_NAME; + cdns_uart_uart_driver->major = CDNS_UART_MAJOR; + cdns_uart_uart_driver->minor = id; + cdns_uart_uart_driver->nr = 1; + #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE - cdns_uart_uart_driver.cons = &cdns_uart_console; + cdns_uart_console = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_console), + GFP_KERNEL); + if (!cdns_uart_console) + return -ENOMEM; + + strncpy(cdns_uart_console->name, CDNS_UART_TTY_NAME, + sizeof(cdns_uart_console->name)); + cdns_uart_console->index = id; + cdns_uart_console->write = cdns_uart_console_write; + cdns_uart_console->device = uart_console_device; + cdns_uart_console->setup = cdns_uart_console_setup; + cdns_uart_console->flags = CON_PRINTBUFFER; + cdns_uart_console->data = cdns_uart_uart_driver; + cdns_uart_uart_driver->cons = cdns_uart_console; #endif - rc = uart_register_driver(&cdns_uart_uart_driver); - if (rc < 0) { - dev_err(&pdev->dev, "Failed to register driver\n"); - return rc; - } + rc = uart_register_driver(cdns_uart_uart_driver); + if (rc < 0) { + dev_err(&pdev->dev, "Failed to register driver\n"); + return rc; } - cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver; + cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver; + + /* + * Setting up proper name_base needs to be done after uart + * registration because tty_driver structure is not filled. + * name_base is 0 by default. + */ + cdns_uart_uart_driver->tty_driver->name_base = id; match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); if (match && match->data) { @@ -1505,7 +1525,6 @@ static int cdns_uart_probe(struct platform_device *pdev) port->flags = UPF_BOOT_AUTOCONF; port->ops = &cdns_uart_ops; port->fifosize = CDNS_UART_FIFO_SIZE; - port->line = id; /* * Register the port. @@ -1536,7 +1555,7 @@ static int cdns_uart_probe(struct platform_device *pdev) console_port = port; #endif - rc = uart_add_one_port(&cdns_uart_uart_driver, port); + rc = uart_add_one_port(cdns_uart_uart_driver, port); if (rc) { dev_err(&pdev->dev, "uart_add_one_port() failed; err=%i\n", rc); @@ -1546,11 +1565,10 @@ static int cdns_uart_probe(struct platform_device *pdev) #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE /* This is not port which is used for console that's why clean it up */ if (console_port == port && - !(cdns_uart_uart_driver.cons->flags & CON_ENABLED)) + !(cdns_uart_uart_driver->cons->flags & CON_ENABLED)) console_port = NULL; #endif - instances++; return 0; err_out_pm_disable: @@ -1566,8 +1584,8 @@ static int cdns_uart_probe(struct platform_device *pdev) err_out_clk_dis_pclk: clk_disable_unprepare(cdns_uart_data->pclk); err_out_unregister_driver: - if (!instances) - uart_unregister_driver(cdns_uart_data->cdns_uart_driver); + uart_unregister_driver(cdns_uart_data->cdns_uart_driver); + return rc; } @@ -1601,8 +1619,7 @@ static int cdns_uart_remove(struct platform_device *pdev) console_port = NULL; #endif - if (!--instances) - uart_unregister_driver(cdns_uart_data->cdns_uart_driver); + uart_unregister_driver(cdns_uart_data->cdns_uart_driver); return rc; } From patchwork Mon Sep 3 13:10:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 10585843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 847A4180E for ; Mon, 3 Sep 2018 13:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74291297C2 for ; Mon, 3 Sep 2018 13:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68641297C8; Mon, 3 Sep 2018 13:17:35 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 0372B297C2 for ; Mon, 3 Sep 2018 13:17:34 +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=BeciVENYA/hEY8gWCaw4tQwCl68w8Jv1zHlgnfqPkbg=; b=himAe8qRQIRqN0WNbWqbj6vM5Z Wmhx4JAOI4R5VJGnXgQNNNay+fiLoIz6hSod0KlaXRa6n1xw+NVpA7dUH803bHZrrDN4bQuLteJVh nk706o5LNWcprSSPLcVJKfNcmvUGe7vVl5opJoZX+ZtYP5iIIngZdDy4iqT+awpu1sj4oKtxBDISB QlZgUDzxdSigY19FXjuAosfY0xsECb2fMuX+mv4LIDrByoccrQr9s+LKYROIH+pFTXc7VrZgJKyQF 8eMbqdIDGTS8CsZkn2/ZAIHUw3WU3dRbSnAhE27yFvBWL/QcqHrlaBZK/WH4AgXgQpZJtRNbsUrVr L1KCoL/w==; 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 1fwojK-0004ki-CM; Mon, 03 Sep 2018 13:17:22 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fwodX-0000tO-H3 for linux-arm-kernel@lists.infradead.org; Mon, 03 Sep 2018 13:11:25 +0000 Received: by mail-wr1-x442.google.com with SMTP id w11-v6so628912wrc.5 for ; Mon, 03 Sep 2018 06:11:16 -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=Z6LGPRKD7iph6AElFmO944nmWy5WoOUM5jIDdjq14Tg=; b=1jRsTiShF23PYuhRzWEaltXcNOGNCZIapBNqWuW0bIWC1P4wy6kfJ1ObDmxiFk/E+X 0vLb1O4a4zGlL5F+bR4i+YRuwQVk6EX4PyjtdZFpw2vQL9QqRylV5W9wIbSUyVsBbuN+ Srg6v00FfSaG3Y0VCnTvypa2oW79qCblNr5qMg4Le5vVzbLrv8mylbMOn+d3TDTgT2KH dCoCn+V/G7z+CB8/h3TCWwMtKjmeY8h6B+TXJ/JUHuNrPifoAo1aQLRGrRvrKHkk+8h0 Vo5KgVAC0Ul2gznrCX6zGPVzVlUQ61+sks2D5r55kZuD2qlWzYYL7pIX6K4GJudBc7/8 c5TQ== 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=Z6LGPRKD7iph6AElFmO944nmWy5WoOUM5jIDdjq14Tg=; b=swlrGGjK2FfMQt/i6Zqhpkobi8i+x7fYmC4YBErYYKV7jttWm1ELPta7QBw2rUFDWL 7Xti1yH85VIA1+IFnfw2DzgVbC/uysfUpVd+6ISVCMzdLTKbWMpRKn8iNYMGUmY5aYoU UoWzLBD5/kIXItn6IvTEXrJi/Vpc9Eg8SCKyUg1BkPTJyTzjlsTRKgClNYf4qcyJmVOp 0kpxOd9BEQH0N4eP2I5ZKJrTB0c7PCzBnV45Fb+fRa2DpfGucupSgC4xngK6kfm+M49V 9OdrgozqouFgLqsdXo/3AsorFiOd6XkN1/VH7YOMQOH9OjfnKbo9I9Z8msDiz70h3aqZ iNKQ== X-Gm-Message-State: APzg51CoYsnit6Tf7H/82ZpXpNfMCp5PP++n58gAHs0XylSwHwNvTqCV tF4332NwgOhbC8wQDeilC6jbTw== X-Google-Smtp-Source: ANB0VdYUmVF98/Z0+gpMfEnEeGtMry6eHDA7/D178yIoU5Fs6/sUabI0dwe/FlhkLHKhlGWKPUqJxQ== X-Received: by 2002:adf:8367:: with SMTP id 94-v6mr19025085wrd.258.1535980275285; Mon, 03 Sep 2018 06:11:15 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id w18-v6sm38300796wrc.38.2018.09.03.06.11.14 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 03 Sep 2018 06:11:14 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu, gnomes@lxorguk.ukuu.org.uk, Alexander Graf , shubhraj@xilinx.com, robh@kernel.org Subject: [PATCH v3 10/10] serial: uartps: Move Port ID to device data structure Date: Mon, 3 Sep 2018 15:10:58 +0200 Message-Id: <9cda66fc3c143cc2055241802300dc12f5571669.1535980253.git.michal.simek@xilinx.com> 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-20180903_061123_603395_1B2A5351 X-CRM114-Status: GOOD ( 16.29 ) 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 Record port ID in device data structure to be have it connected to certain instance. Signed-off-by: Michal Simek --- Changes in v3: - New patch in series Changes in v2: None drivers/tty/serial/xilinx_uartps.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index d838612eda6f..71c032744dae 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -181,6 +181,7 @@ * @pclk: APB clock * @cdns_uart_driver: Pointer to UART driver * @baud: Current baud rate + * @id: Port ID * @clk_rate_change_nb: Notifier block for clock changes * @quirks: Flags for RXBS support. */ @@ -190,6 +191,7 @@ struct cdns_uart { struct clk *pclk; struct uart_driver *cdns_uart_driver; unsigned int baud; + int id; struct notifier_block clk_rate_change_nb; u32 quirks; }; @@ -1376,7 +1378,7 @@ static int __maybe_unused cdns_runtime_resume(struct device *dev) */ static int cdns_uart_probe(struct platform_device *pdev) { - int rc, id, irq; + int rc, irq; struct uart_port *port; struct resource *res; struct cdns_uart *cdns_uart_data; @@ -1402,18 +1404,18 @@ static int cdns_uart_probe(struct platform_device *pdev) return -ENOMEM; /* Look for a serialN alias */ - id = of_alias_get_id(pdev->dev.of_node, "serial"); - if (id < 0) - id = 0; + cdns_uart_data->id = of_alias_get_id(pdev->dev.of_node, "serial"); + if (cdns_uart_data->id < 0) + cdns_uart_data->id = 0; - if (id >= CDNS_UART_NR_PORTS) { + if (cdns_uart_data->id >= CDNS_UART_NR_PORTS) { dev_err(&pdev->dev, "Cannot get uart_port structure\n"); return -ENODEV; } /* There is a need to use unique driver name */ driver_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%d", - CDNS_UART_NAME, id); + CDNS_UART_NAME, cdns_uart_data->id); if (!driver_name) return -ENOMEM; @@ -1421,7 +1423,7 @@ static int cdns_uart_probe(struct platform_device *pdev) cdns_uart_uart_driver->driver_name = driver_name; cdns_uart_uart_driver->dev_name = CDNS_UART_TTY_NAME; cdns_uart_uart_driver->major = CDNS_UART_MAJOR; - cdns_uart_uart_driver->minor = id; + cdns_uart_uart_driver->minor = cdns_uart_data->id; cdns_uart_uart_driver->nr = 1; #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE @@ -1432,7 +1434,7 @@ static int cdns_uart_probe(struct platform_device *pdev) strncpy(cdns_uart_console->name, CDNS_UART_TTY_NAME, sizeof(cdns_uart_console->name)); - cdns_uart_console->index = id; + cdns_uart_console->index = cdns_uart_data->id; cdns_uart_console->write = cdns_uart_console_write; cdns_uart_console->device = uart_console_device; cdns_uart_console->setup = cdns_uart_console_setup; @@ -1454,7 +1456,7 @@ static int cdns_uart_probe(struct platform_device *pdev) * registration because tty_driver structure is not filled. * name_base is 0 by default. */ - cdns_uart_uart_driver->tty_driver->name_base = id; + cdns_uart_uart_driver->tty_driver->name_base = cdns_uart_data->id; match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); if (match && match->data) {