LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: linux-kernel@vger.kernel.org, monstr@monstr.eu,
gnomes@lxorguk.ukuu.org.uk, Alexander Graf <agraf@suse.de>
Cc: Jiri Slaby <jslaby@suse.com>,
linux-serial@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 2/3] serial: uartps: Move register to probe based on run time detection
Date: Thu, 26 Apr 2018 16:08:18 +0200 [thread overview]
Message-ID: <7dc0d444ddfae465a80e509af6ceb6be5b42881a.1524751696.git.michal.simek@xilinx.com> (raw)
In-Reply-To: <cover.1524751696.git.michal.simek@xilinx.com>
In-Reply-To: <cover.1524751696.git.michal.simek@xilinx.com>
Find out the highest serial alias and allocate that amount of
structures/minor numbers to be able to handle all of them.
Origin setting that there are two prealocated CDNS_UART_NR_PORTS is kept
there.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Discussed here: https://patchwork.kernel.org/patch/9738445/
The same solution is done in pl011 driver.
---
drivers/tty/serial/xilinx_uartps.c | 32 ++++++++++++++++--------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index 0fc9de20843c..ffb5b66a05b5 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -1432,6 +1432,22 @@ static int cdns_uart_probe(struct platform_device *pdev)
struct cdns_uart *cdns_uart_data;
const struct of_device_id *match;
+ if (!cdns_uart_uart_driver.state) {
+ rc = of_alias_get_highest_id("serial");
+ if (rc >= CDNS_UART_NR_PORTS) {
+ /* serial2 means 3 ports that's why rc(2) + 1 here */
+ rc += 1;
+ /* Rewrite default setup which is using 2 ports */
+ cdns_uart_uart_driver.nr = 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 = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data),
GFP_KERNEL);
if (!cdns_uart_data)
@@ -1622,28 +1638,14 @@ static struct platform_driver cdns_uart_platform_driver = {
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);
--
2.17.0
next prev parent reply other threads:[~2018-04-26 14:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 14:08 [RFC PATCH 0/3] serial: uartps: Add run time support for more IPs than hardcoded 2 Michal Simek
2018-04-26 14:08 ` [RFC PATCH 1/3] of: base: Introduce of_alias_check_id() to check alias IDs Michal Simek
2018-04-27 2:39 ` Rob Herring
2018-04-27 6:10 ` Michal Simek
2018-04-27 13:02 ` Rob Herring
2018-04-27 14:14 ` Michal Simek
2018-04-27 21:58 ` Alexander Graf
2018-04-26 14:08 ` Michal Simek [this message]
2018-04-26 14:08 ` [RFC PATCH 3/3] serial: uartps: Change uart ports allocation Michal Simek
2018-05-05 13:10 ` [RFC PATCH 0/3] serial: uartps: Add run time support for more IPs than hardcoded 2 Maarten Brock
2018-05-09 12:09 ` Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7dc0d444ddfae465a80e509af6ceb6be5b42881a.1524751696.git.michal.simek@xilinx.com \
--to=michal.simek@xilinx.com \
--cc=agraf@suse.de \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=monstr@monstr.eu \
--subject='Re: [RFC PATCH 2/3] serial: uartps: Move register to probe based on run time detection' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).