aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/8250.c
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2006-01-07 18:18:19 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-01-07 18:18:19 -0500
commita61c2d78ce61e67baf27c43f6721db87a27ac762 (patch)
treec27d0df1c743cff54f15f7476c86ced8917047e5 /drivers/serial/8250.c
parentf61051cd2fc58546f28c226933942d4360810ffb (diff)
[SERIAL] Make the number of UARTs registered configurable.
Also add a nr_uarts module option to the 8250 code to override this, up to a maximum of CONFIG_SERIAL_8250_NR_UARTS This should appease people who complain about a proliferation of /dev/ttyS & /sysfs nodes whilst at the same time allowing a single kernel image to support the rarer occasions of lots of devices. Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/serial/8250.c')
-rw-r--r--drivers/serial/8250.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 1891cf5bdeef..e8454611cb65 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -54,6 +54,8 @@
54 */ 54 */
55static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 55static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
56 56
57static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS;
58
57/* 59/*
58 * Debugging. 60 * Debugging.
59 */ 61 */
@@ -2118,7 +2120,7 @@ static void __init serial8250_isa_init_ports(void)
2118 return; 2120 return;
2119 first = 0; 2121 first = 0;
2120 2122
2121 for (i = 0; i < UART_NR; i++) { 2123 for (i = 0; i < nr_uarts; i++) {
2122 struct uart_8250_port *up = &serial8250_ports[i]; 2124 struct uart_8250_port *up = &serial8250_ports[i];
2123 2125
2124 up->port.line = i; 2126 up->port.line = i;
@@ -2137,7 +2139,7 @@ static void __init serial8250_isa_init_ports(void)
2137 } 2139 }
2138 2140
2139 for (i = 0, up = serial8250_ports; 2141 for (i = 0, up = serial8250_ports;
2140 i < ARRAY_SIZE(old_serial_port) && i < UART_NR; 2142 i < ARRAY_SIZE(old_serial_port) && i < nr_uarts;
2141 i++, up++) { 2143 i++, up++) {
2142 up->port.iobase = old_serial_port[i].port; 2144 up->port.iobase = old_serial_port[i].port;
2143 up->port.irq = irq_canonicalize(old_serial_port[i].irq); 2145 up->port.irq = irq_canonicalize(old_serial_port[i].irq);
@@ -2159,7 +2161,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev)
2159 2161
2160 serial8250_isa_init_ports(); 2162 serial8250_isa_init_ports();
2161 2163
2162 for (i = 0; i < UART_NR; i++) { 2164 for (i = 0; i < nr_uarts; i++) {
2163 struct uart_8250_port *up = &serial8250_ports[i]; 2165 struct uart_8250_port *up = &serial8250_ports[i];
2164 2166
2165 up->port.dev = dev; 2167 up->port.dev = dev;
@@ -2262,7 +2264,7 @@ static int serial8250_console_setup(struct console *co, char *options)
2262 * if so, search for the first available port that does have 2264 * if so, search for the first available port that does have
2263 * console support. 2265 * console support.
2264 */ 2266 */
2265 if (co->index >= UART_NR) 2267 if (co->index >= nr_uarts)
2266 co->index = 0; 2268 co->index = 0;
2267 port = &serial8250_ports[co->index].port; 2269 port = &serial8250_ports[co->index].port;
2268 if (!port->iobase && !port->membase) 2270 if (!port->iobase && !port->membase)
@@ -2298,7 +2300,7 @@ static int __init find_port(struct uart_port *p)
2298 int line; 2300 int line;
2299 struct uart_port *port; 2301 struct uart_port *port;
2300 2302
2301 for (line = 0; line < UART_NR; line++) { 2303 for (line = 0; line < nr_uarts; line++) {
2302 port = &serial8250_ports[line].port; 2304 port = &serial8250_ports[line].port;
2303 if (uart_match_port(p, port)) 2305 if (uart_match_port(p, port))
2304 return line; 2306 return line;
@@ -2420,7 +2422,7 @@ static int __devexit serial8250_remove(struct platform_device *dev)
2420{ 2422{
2421 int i; 2423 int i;
2422 2424
2423 for (i = 0; i < UART_NR; i++) { 2425 for (i = 0; i < nr_uarts; i++) {
2424 struct uart_8250_port *up = &serial8250_ports[i]; 2426 struct uart_8250_port *up = &serial8250_ports[i];
2425 2427
2426 if (up->port.dev == &dev->dev) 2428 if (up->port.dev == &dev->dev)
@@ -2487,7 +2489,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
2487 /* 2489 /*
2488 * First, find a port entry which matches. 2490 * First, find a port entry which matches.
2489 */ 2491 */
2490 for (i = 0; i < UART_NR; i++) 2492 for (i = 0; i < nr_uarts; i++)
2491 if (uart_match_port(&serial8250_ports[i].port, port)) 2493 if (uart_match_port(&serial8250_ports[i].port, port))
2492 return &serial8250_ports[i]; 2494 return &serial8250_ports[i];
2493 2495
@@ -2496,7 +2498,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
2496 * free entry. We look for one which hasn't been previously 2498 * free entry. We look for one which hasn't been previously
2497 * used (indicated by zero iobase). 2499 * used (indicated by zero iobase).
2498 */ 2500 */
2499 for (i = 0; i < UART_NR; i++) 2501 for (i = 0; i < nr_uarts; i++)
2500 if (serial8250_ports[i].port.type == PORT_UNKNOWN && 2502 if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
2501 serial8250_ports[i].port.iobase == 0) 2503 serial8250_ports[i].port.iobase == 0)
2502 return &serial8250_ports[i]; 2504 return &serial8250_ports[i];
@@ -2505,7 +2507,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
2505 * That also failed. Last resort is to find any entry which 2507 * That also failed. Last resort is to find any entry which
2506 * doesn't have a real port associated with it. 2508 * doesn't have a real port associated with it.
2507 */ 2509 */
2508 for (i = 0; i < UART_NR; i++) 2510 for (i = 0; i < nr_uarts; i++)
2509 if (serial8250_ports[i].port.type == PORT_UNKNOWN) 2511 if (serial8250_ports[i].port.type == PORT_UNKNOWN)
2510 return &serial8250_ports[i]; 2512 return &serial8250_ports[i];
2511 2513
@@ -2590,8 +2592,11 @@ static int __init serial8250_init(void)
2590{ 2592{
2591 int ret, i; 2593 int ret, i;
2592 2594
2595 if (nr_uarts > UART_NR)
2596 nr_uarts = UART_NR;
2597
2593 printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " 2598 printk(KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ "
2594 "%d ports, IRQ sharing %sabled\n", (int) UART_NR, 2599 "%d ports, IRQ sharing %sabled\n", nr_uarts,
2595 share_irqs ? "en" : "dis"); 2600 share_irqs ? "en" : "dis");
2596 2601
2597 for (i = 0; i < NR_IRQS; i++) 2602 for (i = 0; i < NR_IRQS; i++)
@@ -2651,6 +2656,9 @@ module_param(share_irqs, uint, 0644);
2651MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices" 2656MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices"
2652 " (unsafe)"); 2657 " (unsafe)");
2653 2658
2659module_param(nr_uarts, uint, 0644);
2660MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")");
2661
2654#ifdef CONFIG_SERIAL_8250_RSA 2662#ifdef CONFIG_SERIAL_8250_RSA
2655module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444); 2663module_param_array(probe_rsa, ulong, &probe_rsa_count, 0444);
2656MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); 2664MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");