fix for 2.1.x ni65 module bug (and other similar drivers)

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Sun, 13 Sep 1998 19:15:47 +0200


the patch below fixes the problem with ni65 driver not working
as module.

the device name string consited of 4 TABs which caused
init_etherdev() net_init.c not to initialze this string
because it didn't start with blanks.

there are some other network drivers which initialze this device name
with a string of blanks too (like 3c523.c). in these drivers those blanks
might get converted by tabs accidently like it happend in ni65.c (because
the 2.0.x source are OK and almost identical!).
browsing through more network driver sources shows that some drives
don't initialize this name buffer, which may cause similar problems
(btw, it's interesting (shocking?!) how many different code versions
for the module/device initialisation can be found).

here is a patch for all those problems:

--- linux-2.1.121/drivers/net/ni65.c.old Sun Sep 13 19:10:50 1998
+++ linux-2.1.121/drivers/net/ni65.c Sun Sep 13 19:31:50 1998
@@ -1167,8 +1167,10 @@
}

#ifdef MODULE
+static char devicename[9] = { 0, };
+
static struct device dev_ni65 = {
- " ", /* "ni6510": device name inserted by net_init.c */
+ devicename, /* "ni6510": device name inserted by net_init.c */
0, 0, 0, 0,
0x360, 9, /* I/O address, IRQ */
0, 0, 0, NULL, ni65_probe };
--- linux-2.1.121/drivers/net/ni52.c~ Fri May 15 03:53:53 1998
+++ linux-2.1.121/drivers/net/ni52.c Sun Sep 13 19:43:20 1998
@@ -1303,8 +1303,9 @@
}

#ifdef MODULE
+static char devicename[9] = { 0, };
static struct device dev_ni52 = {
- " ", /* "ni5210": device name inserted by net_init.c */
+ devicename, /* "ni5210": device name inserted by net_init.c */
0, 0, 0, 0,
0x300, 9, /* I/O address, IRQ */
0, 0, 0, NULL, ni52_probe };
--- linux-2.1.121/drivers/net/atari_bionet.c~ Sat Jun 13 22:28:34 1998
+++ linux-2.1.121/drivers/net/atari_bionet.c Sun Sep 13 19:32:17 1998
@@ -645,7 +645,7 @@

#ifdef MODULE

-static char bio_name[16];
+static char bio_name[16] = { 0, };
static struct device bio_dev =
{
bio_name, /* filled in by register_netdev() */
--- linux-2.1.121/drivers/net/3c523.c~ Mon Mar 23 19:10:34 1998
+++ linux-2.1.121/drivers/net/3c523.c Sun Sep 13 19:32:42 1998
@@ -1255,8 +1255,9 @@
/*************************************************************************/

#ifdef MODULE
+static char devicename[9] = { 0, };
static struct device dev_elmc = {
- " " /*"3c523"*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, elmc_probe };
+ devicename /*"3c523"*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, elmc_probe };

static int irq=0;
static int io=0;
--- linux-2.1.121/drivers/net/cops.c~ Tue Jun 16 08:51:02 1998
+++ linux-2.1.121/drivers/net/cops.c Sun Sep 13 19:36:42 1998
@@ -1026,7 +1026,7 @@
}

#ifdef MODULE
-static char lt_name[16];
+static char lt_name[16] = { 0, };

static struct device cops0_dev =
{
--- linux-2.1.121/drivers/net/de600.c~ Tue Feb 10 21:56:44 1998
+++ linux-2.1.121/drivers/net/de600.c Sun Sep 13 19:37:37 1998
@@ -817,7 +817,7 @@
#endif

#ifdef MODULE
-static char nullname[8];
+static char nullname[8] = { 0, };
static struct device de600_dev = {
nullname, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, de600_probe };

--- linux-2.1.121/drivers/net/dummy.c~ Tue Feb 10 21:56:44 1998
+++ linux-2.1.121/drivers/net/dummy.c Sun Sep 13 19:38:29 1998
@@ -133,7 +133,7 @@
return 0;
}

-static char dummy_name[16];
+static char dummy_name[16] = { 0, };

static struct device dev_dummy = {
dummy_name, /* Needs to be writeable */
--- linux-2.1.121/drivers/net/ni5010.c.~ Tue Feb 10 21:56:45 1998
+++ linux-2.1.121/drivers/net/ni5010.c Sun Sep 13 19:41:50 1998
@@ -771,8 +771,9 @@
}

#ifdef MODULE
+static char devicename[9] = { 0, };
static struct device dev_ni5010 = {
- " ",
+ devicename,
0, 0, 0, 0,
0, 0,
0, 0, 0, NULL, ni5010_probe };
--- linux-2.1.121/drivers/net/atari_pamsnet.c~ Tue Feb 10 21:56:44 1998
+++ linux-2.1.121/drivers/net/atari_pamsnet.c Sun Sep 13 19:35:05 1998
@@ -864,9 +864,10 @@

#ifdef MODULE

+static char devicename[9] = { 0, };
static struct device pam_dev =
{
- " ", /* filled in by register_netdev() */
+ devicename, /* filled in by register_netdev() */
0, 0, 0, 0, /* memory */
0, 0, /* base, irq */
0, 0, 0, NULL, pamsnet_probe,
--- linux-2.1.121/drivers/net/shaper.c~ Sun Aug 9 21:27:52 1998
+++ linux-2.1.121/drivers/net/shaper.c Sun Sep 13 19:44:46 1998
@@ -645,7 +645,7 @@

#ifdef MODULE

-static char devicename[9];
+static char devicename[9] = { 0, };

static struct device dev_shape =
{

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

- 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/faq.html