Skip to content

Commit ba93f2d

Browse files
Karthik Manamcherigratian
authored andcommitted
8250: Make SERIAL_8250_RUNTIME_UARTS work correctly
Consider a situation where I have an ARM based system (such as the Zynq) and therefore no legacy ports. I have three memory-mapped ports (such as cRIO-9068). I use device tree to describe the ports. What would be the config options I set so that I get only the three ports in my system? I do not want legacy ports being created automatically and I want it to be flexible enough that it creates the devices based only on the device tree. I expected setting SERIAL_8250_RUNTIME_UARTS = 0 to work because the description said, "Set this to the maximum number of serial ports you want the kernel to register at boot time." Unfortunately, even though SERIAL_8250_NR_UARTS was set to the default value of 4, I did not get any device nodes (because SERIAL_8250_RUNTIME_UARTS was 0). This is what this change is addressing. SERIAL_8250_NR_UARTS controls the maximum number of ports you can support. SERIAL_8250_RUNTIME_UARTS specifies the number of ports you want to create automatically for legacy ports at boot time. All other ports will be created when serial8250_register_port is called (and if it does not exceed the total number of supported ports as specified by SERIAL_8250_NR_UARTS). Signed-off-by: Karthik Manamcheri <karthik.manamcheri@ni.com> Acked-by: Jaeden Amero <jaeden.amero@ni.com>
1 parent 3089f71 commit ba93f2d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/tty/serial/8250/8250_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static void __init serial8250_isa_init_ports(void)
505505
if (nr_uarts > UART_NR)
506506
nr_uarts = UART_NR;
507507

508-
for (i = 0; i < nr_uarts; i++) {
508+
for (i = 0; i < UART_NR; i++) {
509509
struct uart_8250_port *up = &serial8250_ports[i];
510510
struct uart_port *port = &up->port;
511511

@@ -606,7 +606,7 @@ static int univ8250_console_setup(struct console *co, char *options)
606606
* if so, search for the first available port that does have
607607
* console support.
608608
*/
609-
if (co->index >= nr_uarts)
609+
if (co->index >= UART_NR)
610610
co->index = 0;
611611
port = &serial8250_ports[co->index].port;
612612
/* link port to console */
@@ -659,7 +659,7 @@ static int univ8250_console_match(struct console *co, char *name, int idx,
659659
return -ENODEV;
660660

661661
/* try to match the port specified on the command line */
662-
for (i = 0; i < nr_uarts; i++) {
662+
for (i = 0; i < UART_NR; i++) {
663663
struct uart_port *port = &serial8250_ports[i].port;
664664

665665
if (port->iotype != iotype)
@@ -867,7 +867,7 @@ static int serial8250_remove(struct platform_device *dev)
867867
{
868868
int i;
869869

870-
for (i = 0; i < nr_uarts; i++) {
870+
for (i = 0; i < UART_NR; i++) {
871871
struct uart_8250_port *up = &serial8250_ports[i];
872872

873873
if (up->port.dev == &dev->dev)
@@ -934,7 +934,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
934934
/*
935935
* First, find a port entry which matches.
936936
*/
937-
for (i = 0; i < nr_uarts; i++)
937+
for (i = 0; i < UART_NR; i++)
938938
if (uart_match_port(&serial8250_ports[i].port, port))
939939
return &serial8250_ports[i];
940940

@@ -948,7 +948,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
948948
* free entry. We look for one which hasn't been previously
949949
* used (indicated by zero iobase).
950950
*/
951-
for (i = 0; i < nr_uarts; i++)
951+
for (i = 0; i < UART_NR; i++)
952952
if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
953953
serial8250_ports[i].port.iobase == 0)
954954
return &serial8250_ports[i];
@@ -957,7 +957,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(const struct uart_
957957
* That also failed. Last resort is to find any entry which
958958
* doesn't have a real port associated with it.
959959
*/
960-
for (i = 0; i < nr_uarts; i++)
960+
for (i = 0; i < UART_NR; i++)
961961
if (serial8250_ports[i].port.type == PORT_UNKNOWN)
962962
return &serial8250_ports[i];
963963

0 commit comments

Comments
 (0)