From patchwork Fri Mar 24 16:26:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 95967 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp127030obz; Fri, 24 Mar 2017 09:26:49 -0700 (PDT) X-Received: by 10.99.0.149 with SMTP id 143mr10000095pga.118.1490372809596; Fri, 24 Mar 2017 09:26:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t66si3433212pgb.85.2017.03.24.09.26.49; Fri, 24 Mar 2017 09:26:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936794AbdCXQ0l (ORCPT + 2 others); Fri, 24 Mar 2017 12:26:41 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42857 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936433AbdCXQ0j (ORCPT ); Fri, 24 Mar 2017 12:26:39 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 867D7269EA1 Received: by dawn.luon.net (Postfix, from userid 1000) id 2E4E628B1FFD; Fri, 24 Mar 2017 17:26:35 +0100 (CET) From: Sjoerd Simons To: linux-serial@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Russell King , Jiri Slaby Subject: [PATCH 1/2] serial: pl010: Move uart_register_driver call to device probe Date: Fri, 24 Mar 2017 17:26:33 +0100 Message-Id: <20170324162634.8880-2-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170324162634.8880-1-sjoerd.simons@collabora.co.uk> References: <20170324162634.8880-1-sjoerd.simons@collabora.co.uk> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org uart_register_driver call binds the driver to a specific device node through tty_register_driver call. This should typically happen during device probe call. In a multiplatform scenario, it is possible that multiple serial drivers are part of the kernel. Currently the driver registration fails if multiple serial drivers with overlapping major/minor numbers are included. Signed-off-by: Sjoerd Simons --- drivers/tty/serial/amba-pl010.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index f2f251075109..74a1d3b2e45d 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c @@ -749,6 +749,16 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id) amba_ports[i] = uap; amba_set_drvdata(dev, uap); + + if (!amba_reg.state) { + ret = uart_register_driver(&amba_reg); + if (ret < 0) { + dev_err(uap->port.dev, + "Failed to register AMBA-PL010 driver\n"); + return ret; + } + } + ret = uart_add_one_port(&amba_reg, &uap->port); if (ret) amba_ports[i] = NULL; @@ -760,12 +770,18 @@ static int pl010_remove(struct amba_device *dev) { struct uart_amba_port *uap = amba_get_drvdata(dev); int i; + bool busy = false; uart_remove_one_port(&amba_reg, &uap->port); for (i = 0; i < ARRAY_SIZE(amba_ports); i++) if (amba_ports[i] == uap) amba_ports[i] = NULL; + else if (amba_ports[i]) + busy = true; + + if (!busy) + uart_unregister_driver(&amba_reg); return 0; } @@ -816,23 +832,14 @@ static struct amba_driver pl010_driver = { static int __init pl010_init(void) { - int ret; - printk(KERN_INFO "Serial: AMBA driver\n"); - ret = uart_register_driver(&amba_reg); - if (ret == 0) { - ret = amba_driver_register(&pl010_driver); - if (ret) - uart_unregister_driver(&amba_reg); - } - return ret; + return amba_driver_register(&pl010_driver); } static void __exit pl010_exit(void) { amba_driver_unregister(&pl010_driver); - uart_unregister_driver(&amba_reg); } module_init(pl010_init); From patchwork Fri Mar 24 16:26:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 95968 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp127077obz; Fri, 24 Mar 2017 09:26:57 -0700 (PDT) X-Received: by 10.99.142.67 with SMTP id k64mr9892089pge.31.1490372817615; Fri, 24 Mar 2017 09:26:57 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si3438316pls.104.2017.03.24.09.26.57; Fri, 24 Mar 2017 09:26:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966573AbdCXQ0x (ORCPT + 2 others); Fri, 24 Mar 2017 12:26:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42855 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965886AbdCXQ0t (ORCPT ); Fri, 24 Mar 2017 12:26:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 802EF269E9D Received: by dawn.luon.net (Postfix, from userid 1000) id 7A96928B1FFF; Fri, 24 Mar 2017 17:26:35 +0100 (CET) From: Sjoerd Simons To: linux-serial@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 2/2] serial: sh-sci: Move uart_register_driver call to device probe Date: Fri, 24 Mar 2017 17:26:34 +0100 Message-Id: <20170324162634.8880-3-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170324162634.8880-1-sjoerd.simons@collabora.co.uk> References: <20170324162634.8880-1-sjoerd.simons@collabora.co.uk> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org uart_register_driver call binds the driver to a specific device node through tty_register_driver call. This should typically happen during device probe call. In a multiplatform scenario, it is possible that multiple serial drivers are part of the kernel. Currently the driver registration fails if multiple serial drivers with overlapping major/minor numbers are included. Signed-off-by: Sjoerd Simons --- drivers/tty/serial/sh-sci.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 9a47cc4f16a2..7c1c0c08459e 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3063,6 +3063,12 @@ static int sci_probe_single(struct platform_device *dev, return -EINVAL; } + if (!sci_uart_driver.state) { + ret = uart_register_driver(&sci_uart_driver); + if (ret) + return ret; + } + ret = sci_init_single(dev, sciport, index, p, false); if (ret) return ret; @@ -3186,24 +3192,17 @@ static struct platform_driver sci_driver = { static int __init sci_init(void) { - int ret; - pr_info("%s\n", banner); - ret = uart_register_driver(&sci_uart_driver); - if (likely(ret == 0)) { - ret = platform_driver_register(&sci_driver); - if (unlikely(ret)) - uart_unregister_driver(&sci_uart_driver); - } - - return ret; + return platform_driver_register(&sci_driver); } static void __exit sci_exit(void) { platform_driver_unregister(&sci_driver); - uart_unregister_driver(&sci_uart_driver); + + if (sci_uart_driver.state) + uart_unregister_driver(&sci_uart_driver); } #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE