[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>
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c
index 70a09a3..707c5b0 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/serial/suncore.c
@@ -23,11 +23,36 @@
#include "suncore.h"
-int sunserial_current_minor = 64;
+static int sunserial_current_minor = 64;
-EXPORT_SYMBOL(sunserial_current_minor);
+int sunserial_register_minors(struct uart_driver *drv, int count)
+{
+ int err = 0;
-int sunserial_console_match(struct console *con, struct device_node *dp,
+ drv->minor = sunserial_current_minor;
+ drv->nr += count;
+ /* Register the driver on the first call */
+ if (drv->nr == count)
+ err = uart_register_driver(drv);
+ if (err == 0) {
+ sunserial_current_minor += count;
+ drv->tty_driver->name_base = drv->minor - 64;
+ }
+ return err;
+}
+EXPORT_SYMBOL(sunserial_register_minors);
+
+void sunserial_unregister_minors(struct uart_driver *drv, int count)
+{
+ drv->nr -= count;
+ sunserial_current_minor -= count;
+
+ if (drv->nr == 0)
+ uart_unregister_driver(drv);
+}
+EXPORT_SYMBOL(sunserial_unregister_minors);
+
+int __init sunserial_console_match(struct console *con, struct device_node *dp,
struct uart_driver *drv, int line)
{
int off;
@@ -133,8 +158,6 @@
con->cflag = cflag;
}
-EXPORT_SYMBOL(sunserial_console_termios);
-
/* Sun serial MOUSE auto baud rate detection. */
static struct mouse_baud_cflag {
int baud;