lkml.org 
[lkml]   [1999]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Serial driver size reducing (2.3.29)
Hi all !

This small patch reduces size of serial driver by 4k when it compiled
into the kernel.

1) added '__init' to probe_serial_pci() definition;
2) added #ifdef MODULE around pci_board_inst[] array declaration and usage.
As I understand it is safe because serial driver compiled into the kernel
doesn't unregister serial devices (except PCMCIA). Also added '__initdata'
to pci_boards[] declaration (for same reason);
3) added '__initdata' to some text constants (may be overkill :))

I hope it will be usefull.

Andrey.

--- /mnt/c/linux/drivers/char/serial.c Sat Nov 20 18:21:16 1999
+++ /linux/drivers/char/serial.c Fri Nov 26 17:07:19 1999
@@ -44,8 +44,8 @@
* int rs_init(void);
*/

-static char *serial_version = "4.91";
-static char *serial_revdate = "1999-11-17";
+#define VERSION "4.91"
+#define DATE "1999-11-17"

/*
* Serial driver configuration section. Here are the various options:
@@ -226,7 +235,9 @@
#define _INLINE_
#endif

-static char *serial_name = "Serial driver";
+static char serial_name[] __initdata = "Serial driver";
+static char serial_version[] __initdata = VERSION;
+static char serial_revdate[] __initdata = DATE;

static DECLARE_TASK_QUEUE(tq_serial);

@@ -266,7 +266,7 @@
* Here we define the default xmit fifo size used for each type of
* UART
*/
-static struct serial_uart_config uart_config[] = {
+static struct serial_uart_config uart_config[] __initdata = {
{ "unknown", 1, 0 },
{ "8250", 1, 0 },
{ "16450", 1, 0 },
@@ -294,8 +294,10 @@

#ifdef ENABLE_SERIAL_PCI
#define NR_PCI_BOARDS 8
+#ifdef MODULE
static struct pci_board_inst serial_pci_board[NR_PCI_BOARDS];
static int serial_pci_board_idx = 0;
+#endif
#ifdef PCI_NUM_RESOURCES
#define PCI_BASE_ADDRESS(dev, r) ((dev)->resource[r].start)
#else
@@ -3125,43 +3138,49 @@
* number, and identifies which options were configured into this
* driver.
*/
-static _INLINE_ void show_serial_version(void)
-{
- printk(KERN_INFO "%s version %s%s (%s) with", serial_name,
- serial_version, LOCAL_VERSTRING, serial_revdate);
+static char serial_options[] __initdata =
#ifdef CONFIG_HUB6
- printk(" HUB-6");
+ " HUB-6"
#define SERIAL_OPT
#endif
#ifdef CONFIG_SERIAL_MANY_PORTS
- printk(" MANY_PORTS");
+ " MANY_PORTS"
#define SERIAL_OPT
#endif
#ifdef CONFIG_SERIAL_MULTIPORT
- printk(" MULTIPORT");
+ " MULTIPORT"
#define SERIAL_OPT
#endif
#ifdef CONFIG_SERIAL_SHARE_IRQ
- printk(" SHARE_IRQ");
+ " SHARE_IRQ"
#define SERIAL_OPT
#endif
#ifdef CONFIG_SERIAL_DETECT_IRQ
- printk(" DETECT_IRQ");
+ " DETECT_IRQ"
#define SERIAL_OPT
#endif
#ifdef ENABLE_SERIAL_PCI
- printk(" SERIAL_PCI");
+ " SERIAL_PCI"
#ifdef CONFIG_SERIAL_PCI_MEMMAPPED
- printk(" PCI_IOMEM");
+ " PCI_IOMEM"
+#endif
+#define SERIAL_OPT
#endif
+#ifdef ENABLE_SERIAL_PNP
+ " ISAPNP"
#define SERIAL_OPT
#endif
#ifdef SERIAL_OPT
- printk(" enabled\n");
+ " enabled\n";
#else
- printk(" no serial options enabled\n");
+ " no serial options enabled\n";
#endif
#undef SERIAL_OPT
+
+static _INLINE_ void show_serial_version(void)
+{
+ printk(KERN_INFO "%s version %s%s (%s) with%s", serial_name,
+ serial_version, LOCAL_VERSTRING, serial_revdate, serial_options);
}

/*
@@ -3655,7 +3657,7 @@
* This is the configuration table for all of the PCI serial boards
* which we support.
*/
-static struct pci_board pci_boards[] = {
+static struct pci_board pci_boards[] __initdata = {
/*
* Vendor ID, Device ID,
* Subvendor ID, Subdevice ID,
@@ -3988,7 +3990,7 @@
* Accept a maximum of eight boards
*
*/
-static void probe_serial_pci(void)
+static void __init probe_serial_pci(void)
{
u16 subvendor, subdevice;
int k, line;
@@ -4050,7 +4052,7 @@
if (board->init_fn)
if ((board->init_fn)(dev, board, 1) != 0)
continue;
-
+#ifdef MODULE
/*
* Register the serial board in the array so we can
* shutdown the board later, if necessary.
@@ -4060,7 +4062,7 @@
serial_pci_board[serial_pci_board_idx].board = board;
serial_pci_board[serial_pci_board_idx].dev = dev;
serial_pci_board_idx++;
-
+#endif
base_idx = board->flags & SPCI_FL_BASE_MASK;
port = PCI_BASE_ADDRESS(dev, base_idx) +
board->first_uart_offset;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site