From: "Martin Hundebøll" <martin@geanix.com>
To: linux-serial@vger.kernel.org
Cc: "Martin Hundebøll" <martin@geanix.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Subject: [PATCH v2 1/3] serial: 8250: allow use of non-runtime configured uart ports
Date: Tue, 18 Oct 2022 15:34:17 +0200 [thread overview]
Message-ID: <20221018133419.134110-1-martin@geanix.com> (raw)
The logic to find unused ports when registering new 8250 uart ports
searches only up to CONFIG_SERIAL_8250_RUNTIME_UARTS, which forces users
of external 8250 ports to increase the number of runtime ports
artificially.
Fix this by initializing each allocated port structure with basic
settings like line number and uart operation callbacks, and by searching
the entire array of allocated ports to find an unused one.
Signed-off-by: Martin Hundebøll <martin@geanix.com>
---
drivers/tty/serial/8250/8250_core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 94fbf0add2ce..a166cc66e7d1 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -500,7 +500,7 @@ static void __init serial8250_isa_init_ports(void)
if (nr_uarts > UART_NR)
nr_uarts = UART_NR;
- for (i = 0; i < nr_uarts; i++) {
+ for (i = 0; i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[i];
struct uart_port *port = &up->port;
@@ -926,15 +926,16 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
/* try line number first if still available */
i = port->line;
- if (i < nr_uarts && serial8250_ports[i].port.type == PORT_UNKNOWN &&
+ if (i < UART_NR && serial8250_ports[i].port.type == PORT_UNKNOWN &&
serial8250_ports[i].port.iobase == 0)
return &serial8250_ports[i];
+
/*
* We didn't find a matching entry, so look for the first
* free entry. We look for one which hasn't been previously
* used (indicated by zero iobase).
*/
- for (i = 0; i < nr_uarts; i++)
+ for (i = 0; i < UART_NR; i++)
if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
serial8250_ports[i].port.iobase == 0)
return &serial8250_ports[i];
@@ -943,7 +944,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
* That also failed. Last resort is to find any entry which
* doesn't have a real port associated with it.
*/
- for (i = 0; i < nr_uarts; i++)
+ for (i = 0; i < UART_NR; i++)
if (serial8250_ports[i].port.type == PORT_UNKNOWN)
return &serial8250_ports[i];
--
2.38.0
next reply other threads:[~2022-10-18 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 13:34 Martin Hundebøll [this message]
2022-10-18 13:34 ` [PATCH v2 2/3] serial: 8250: allow zero runtime-configured ports Martin Hundebøll
2022-10-18 13:34 ` [PATCH v2 3/3] serial: 8250: skip platform device registration with no runtime ports Martin Hundebøll
2022-10-20 13:00 ` Ilpo Järvinen
2022-10-20 12:34 ` [PATCH v2 1/3] serial: 8250: allow use of non-runtime configured uart ports Ilpo Järvinen
2022-10-20 14:10 ` Martin Hundebøll
2022-10-20 14:14 ` Ilpo Järvinen
2022-10-20 18:34 ` Martin Hundebøll
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=20221018133419.134110-1-martin@geanix.com \
--to=martin@geanix.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox