aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/sunzilog.c
diff options
context:
space:
mode:
authorMartin Habets <errandir_news@mph.eclipse.co.uk>2007-12-11 03:37:04 -0800
committerDavid S. Miller <davem@sunset.davemloft.net>2007-12-12 07:36:34 -0800
commit58d784a5c754cd66ecd4791222162504d3c16c74 (patch)
treea25670e8dd1569cf5084af790873b246f45134c3 /drivers/serial/sunzilog.c
parentRevert "make bnx2x select ZLIB_INFLATE" (diff)
downloadlinux-dev-58d784a5c754cd66ecd4791222162504d3c16c74.tar.xz
linux-dev-58d784a5c754cd66ecd4791222162504d3c16c74.zip
[SERIAL] sparc: Infrastructure to fix section mismatch bugs.
This patch against 2.6.23 sparc-2.6.git contains a number of minor cleanups of the sparc serial drivers. Initially I fixed this build warning: WARNING: vmlinux.o(.text+0x107a2c): Section mismatch: reference to .init.text:add_preferred_console (between 'sunserial_console_match' and 'sunserial_console_termios') which is done by declaring sunserial_console_match() as __init. This resulted in build warnings on sunserial_current_minor. To resolve these the variable was changed so it is no longer global, and to hide operations on it inside 2 new functions. These functions handle the UART minor handling code that is common to all sparc serial drivers. These changes allowed to clean up the uart counters in all the sparc serial drivers, and the administration of minor device numbers. Lastly, sunserial_console_termios() does not need to be exported since it is only called from non-modular code. Sadly, the following build warning still exists: WARNING: vmlinux.o(__ksymtab+0x2910): Section mismatch: reference to .init.text:sunserial_console_match (between '__ksymtab_sunserial_console_match' and '__ksymtab_sunserial_unregister_minors') This could be resolved by not exporting sunserial_console_match(), but this is not possible at the moment because it is being called from modular code. On the other hand, this is a bogus warning since it comes from a ksymtab section. Signed-off-by: Martin Habets <errandir_news@mph.eclipse.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/serial/sunzilog.c')
-rw-r--r--drivers/serial/sunzilog.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 283bef0d24cb..cb2e40506379 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -63,10 +63,6 @@
readb(&((__channel)->control))
#endif
-static int num_sunzilog;
-#define NUM_SUNZILOG num_sunzilog
-#define NUM_CHANNELS (NUM_SUNZILOG * 2)
-
#define ZS_CLOCK 4915200 /* Zilog input clock rate. */
#define ZS_CLOCK_DIVISOR 16 /* Divisor this driver uses. */
@@ -1031,18 +1027,19 @@ static struct uart_driver sunzilog_reg = {
.major = TTY_MAJOR,
};
-static int __init sunzilog_alloc_tables(void)
+static int __init sunzilog_alloc_tables(int num_sunzilog)
{
struct uart_sunzilog_port *up;
unsigned long size;
+ int num_channels = num_sunzilog * 2;
int i;
- size = NUM_CHANNELS * sizeof(struct uart_sunzilog_port);
+ size = num_channels * sizeof(struct uart_sunzilog_port);
sunzilog_port_table = kzalloc(size, GFP_KERNEL);
if (!sunzilog_port_table)
return -ENOMEM;
- for (i = 0; i < NUM_CHANNELS; i++) {
+ for (i = 0; i < num_channels; i++) {
up = &sunzilog_port_table[i];
spin_lock_init(&up->port.lock);
@@ -1050,13 +1047,13 @@ static int __init sunzilog_alloc_tables(void)
if (i == 0)
sunzilog_irq_chain = up;
- if (i < NUM_CHANNELS - 1)
+ if (i < num_channels - 1)
up->next = up + 1;
else
up->next = NULL;
}
- size = NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *);
+ size = num_sunzilog * sizeof(struct zilog_layout __iomem *);
sunzilog_chip_regs = kzalloc(size, GFP_KERNEL);
if (!sunzilog_chip_regs) {
kfree(sunzilog_port_table);
@@ -1496,34 +1493,28 @@ static int __init sunzilog_init(void)
struct device_node *dp;
int err, uart_count;
int num_keybms;
+ int num_sunzilog = 0;
- NUM_SUNZILOG = 0;
num_keybms = 0;
for_each_node_by_name(dp, "zs") {
- NUM_SUNZILOG++;
+ num_sunzilog++;
if (of_find_property(dp, "keyboard", NULL))
num_keybms++;
}
uart_count = 0;
- if (NUM_SUNZILOG) {
+ if (num_sunzilog) {
int uart_count;
- err = sunzilog_alloc_tables();
+ err = sunzilog_alloc_tables(num_sunzilog);
if (err)
goto out;
- uart_count = (NUM_SUNZILOG * 2) - (2 * num_keybms);
+ uart_count = (num_sunzilog * 2) - (2 * num_keybms);
- sunzilog_reg.nr = uart_count;
- sunzilog_reg.minor = sunserial_current_minor;
- err = uart_register_driver(&sunzilog_reg);
+ err = sunserial_register_minors(&sunzilog_reg, uart_count);
if (err)
goto out_free_tables;
-
- sunzilog_reg.tty_driver->name_base = sunzilog_reg.minor - 64;
-
- sunserial_current_minor += uart_count;
}
err = of_register_driver(&zs_driver, &of_bus_type);
@@ -1557,8 +1548,8 @@ out_unregister_driver:
of_unregister_driver(&zs_driver);
out_unregister_uart:
- if (NUM_SUNZILOG) {
- uart_unregister_driver(&sunzilog_reg);
+ if (num_sunzilog) {
+ sunserial_unregister_minors(&sunzilog_reg, num_sunzilog);
sunzilog_reg.cons = NULL;
}
@@ -1590,8 +1581,8 @@ static void __exit sunzilog_exit(void)
zilog_irq = -1;
}
- if (NUM_SUNZILOG) {
- uart_unregister_driver(&sunzilog_reg);
+ if (sunzilog_reg.nr) {
+ sunserial_unregister_minors(&sunzilog_reg, sunzilog_reg.nr);
sunzilog_free_tables();
}
}