[PATCH] more __init in network drivers

From: Andrzej Krzysztofowicz (ankry@green.mif.pg.gda.pl)
Date: Thu Jul 13 2000 - 16:49:35 EST


Hi,

The following patch moves some network drivers code/data in test4-pre6 into
__init / __initdata sections.

BTW, what is the reason that the initial "version" string (containing driver
name, its version and author(s)) is not marked __initdata in most drivers ?
It looks to be intentional.
Does it really need to persist in MEMORY after start ?

Regards
   Andrzej
*************************************************************************

diff -u --recursive linux-2.4test4-6/drivers/net/3c505.c linux/drivers/net/3c505.c
--- linux-2.4test4-6/drivers/net/3c505.c Tue May 2 21:40:58 2000
+++ linux/drivers/net/3c505.c Thu Jul 13 12:57:58 2000
@@ -130,15 +130,16 @@
 #define INVALID_PCB_MSG(len) \
         printk(invalid_pcb_msg, (len),filename,__FUNCTION__,__LINE__)
 
-static const char *search_msg = "%s: Looking for 3c505 adapter at address %#x...";
+static const char *search_msg __initdata =
+ "%s: Looking for 3c505 adapter at address %#x...";
 
-static const char *stilllooking_msg = "still looking...";
+static const char *stilllooking_msg __initdata = "still looking...";
 
-static const char *found_msg = "found.\n";
+static const char *found_msg __initdata = "found.\n";
 
-static const char *notfound_msg = "not found (reason = %d)\n";
+static const char *notfound_msg __initdata = "not found (reason = %d)\n";
 
-static const char *couldnot_msg = "%s: 3c505 not found\n";
+static const char *couldnot_msg __initdata = "%s: 3c505 not found\n";
 
 /*********************************************************
  *
@@ -180,7 +181,7 @@
  * Last element MUST BE 0!
  *****************************************************************/
 
-static const int addr_list[] __initdata = {0x300, 0x280, 0x310, 0};
+static int addr_list[] __initdata = {0x300, 0x280, 0x310, 0};
 
 /* Dma Memory related stuff */
 
diff -u --recursive linux-2.4test4-6/drivers/net/3c509.c linux/drivers/net/3c509.c
--- linux-2.4test4-6/drivers/net/3c509.c Thu Jul 13 12:56:16 2000
+++ linux/drivers/net/3c509.c Thu Jul 13 12:57:58 2000
@@ -66,6 +66,7 @@
 #include <linux/skbuff.h>
 #include <linux/delay.h> /* for udelay() */
 #include <linux/spinlock.h>
+#include <linux/init.h>
 
 #include <asm/bitops.h>
 #include <asm/io.h>
@@ -158,7 +159,7 @@
         int id;
 };
 
-struct el3_mca_adapters_struct el3_mca_adapters[] = {
+struct el3_mca_adapters_struct el3_mca_adapters[] __initdata = {
         { "3Com 3c529 EtherLink III (10base2)", 0x627c },
         { "3Com 3c529 EtherLink III (10baseT)", 0x627d },
         { "3Com 3c529 EtherLink III (test mode)", 0x62db },
@@ -173,7 +174,7 @@
         unsigned short vendor, function;
         char *name;
 };
-struct el3_isapnp_adapters_struct el3_isapnp_adapters[] = {
+struct el3_isapnp_adapters_struct el3_isapnp_adapters[] __initdata = {
         {ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5090), "3Com Etherlink III (TP)"},
         {ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5091), "3Com Etherlink III"},
         {ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5094), "3Com Etherlink III (combo)"},
@@ -182,7 +183,7 @@
         {ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x80f8), "3Com Etherlink III compatible"},
         {0, }
 };
-u16 el3_isapnp_phys_addr[8][3] = {
+u16 el3_isapnp_phys_addr[8][3] __initdata = {
         {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
         {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}
 };
@@ -191,7 +192,7 @@
 static int nopnp = 0;
 #endif
 
-int el3_probe(struct net_device *dev)
+int __init el3_probe(struct net_device *dev)
 {
         short lrs_state = 0xff, i;
         int ioaddr, irq, if_port;
@@ -491,7 +492,7 @@
 /* Read a word from the EEPROM using the regular EEPROM access register.
    Assume that we are in register window zero.
  */
-static ushort read_eeprom(int ioaddr, int index)
+static ushort __init read_eeprom(int ioaddr, int index)
 {
         outw(EEPROM_READ + index, ioaddr + 10);
         /* Pause for at least 162 us. for the read to take place. */
@@ -500,7 +501,7 @@
 }
 
 /* Read a word from the EEPROM when in the ISA ID probe state. */
-static ushort id_read_eeprom(int index)
+static ushort __init id_read_eeprom(int index)
 {
         int bit, word = 0;
 
diff -u --recursive linux-2.4test4-6/drivers/net/3c515.c linux/drivers/net/3c515.c
--- linux-2.4test4-6/drivers/net/3c515.c Thu Jul 13 12:56:16 2000
+++ linux/drivers/net/3c515.c Thu Jul 13 13:32:54 2000
@@ -70,6 +70,7 @@
 
 #define NEW_MULTICAST
 #include <linux/delay.h>
+#include <linux/init.h>
 
 /* Kernel version compatibility functions. */
 #define RUN_AT(x) (jiffies + (x))
@@ -356,11 +357,11 @@
         unsigned short vendor, function;
         char *name;
 };
-struct corkscrew_isapnp_adapters_struct corkscrew_isapnp_adapters[] = {
+struct corkscrew_isapnp_adapters_struct corkscrew_isapnp_adapters[] __initdata = {
         {ISAPNP_VENDOR('T', 'C', 'M'), ISAPNP_FUNCTION(0x5051), "3Com Fast EtherLink ISA"},
         {0, }
 };
-int corkscrew_isapnp_phys_addr[3] = {
+int corkscrew_isapnp_phys_addr[3] __initdata = {
         0, 0, 0
 };
 
@@ -424,7 +425,7 @@
 }
 
 #else
-int tc515_probe(struct net_device *dev)
+int __init tc515_probe(struct net_device *dev)
 {
         int cards_found = 0;
 
@@ -437,7 +438,7 @@
 }
 #endif /* not MODULE */
 
-static int corkscrew_scan(struct net_device *dev)
+static int __init corkscrew_scan(struct net_device *dev)
 {
         int cards_found = 0;
         static int ioaddr;
@@ -548,7 +549,7 @@
         return cards_found;
 }
 
-static struct net_device *corkscrew_found_device(struct net_device *dev,
+static struct net_device __init *corkscrew_found_device(struct net_device *dev,
                                                  int ioaddr, int irq,
                                                  int product_index,
                                                  int options)
@@ -619,7 +620,7 @@
         return dev;
 }
 
-static int corkscrew_probe1(struct net_device *dev)
+static int __init corkscrew_probe1(struct net_device *dev)
 {
         int ioaddr = dev->base_addr;
         struct corkscrew_private *vp =
diff -u --recursive linux-2.4test4-6/drivers/net/3c527.c linux/drivers/net/3c527.c
--- linux-2.4test4-6/drivers/net/3c527.c Tue May 2 21:40:59 2000
+++ linux/drivers/net/3c527.c Thu Jul 13 13:10:01 2000
@@ -146,7 +146,7 @@
         char *name;
 };
 
-const struct mca_adapters_t mc32_adapters[] = {
+const struct mca_adapters_t mc32_adapters[] __initdata = {
         { 0x0041, "3COM EtherLink MC/32" },
         { 0x8EF5, "IBM High Performance Lan Adapter" },
         { 0x0000, NULL }
diff -u --recursive linux-2.4test4-6/drivers/net/ne2.c linux/drivers/net/ne2.c
--- linux-2.4test4-6/drivers/net/ne2.c Mon Jun 19 22:30:58 2000
+++ linux/drivers/net/ne2.c Thu Jul 13 12:57:58 2000
@@ -110,16 +110,16 @@
 #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
 
 /* From the .ADF file: */
-static unsigned int addresses[7]=
+static unsigned int addresses[7] __initdata =
                 {0x1000, 0x2020, 0x8020, 0xa0a0, 0xb0b0, 0xc0c0, 0xc3d0};
-static int irqs[4] = {3, 4, 5, 9};
+static int irqs[4] __initdata = {3, 4, 5, 9};
 
 struct ne2_adapters_t {
         unsigned int id;
         char *name;
 };
 
-const struct ne2_adapters_t ne2_adapters[] = {
+const struct ne2_adapters_t ne2_adapters[] __initdata = {
         { 0x6354, "Arco Ethernet Adapter AE/2" },
         { 0x70DE, "Compex ENET-16 MC/P" },
         { 0x7154, "Novell Ethernet Adapter NE/2" },
*************************************************************************

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

- 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/



This archive was generated by hypermail 2b29 : Sat Jul 15 2000 - 21:00:18 EST