Building WAN card driver as monolythic (2nd round)

Linux Lists (lists@cyclades.com)
Fri, 3 Dec 1999 14:19:19 -0800 (PST)


Hello,

I'm restarting this thread, as I couldn't quite get it solved for 2.2.x
kernels. So, continuing from where we stopped ... :)

On Wed, 17 Nov 1999, Alan Cox wrote:

> > found the file drivers/net/Space.c, where all probe functions from
> > configured devices are called from. However, it seems that this is
> > supposed to be used only by Ethernet devices.
>
> Not so. Look at for example the loopback drivers, the appletalk drivers etc.
> For 2.3.28 look at drivers/net/setup.,c

Perfect, for 2.3.x, it's a walk in the park. The driver is already working
as a module and as monotythic, with the addition of just 4 lines of code
in drivers/net/setup.c . That was beautiful ... :)

However, the same can't be said for 2.2.x (just for reference, I'm using
2.2.13 for this case). What I'm doing in order to provide the monolythic
support is as follows:

- Add the following code to linux/drivers/net/Space.c:

--- linux/drivers/net/Space.c.orig Tue Oct 19 17:14:01 1999
+++ linux/drivers/net/Space.c Fri Dec 3 11:55:08 1999
@@ -889,6 +889,15 @@
#define NEXT_DEV (&sbni0_dev)
#endif

+#ifdef CONFIG_PC300
+extern int cpc_probe(struct device *);
+
+static struct device cpc_dev =
+ {"cpc", 0, 0, 0, 0, 0, 0, 0, 0, 0, NEXT_DEV, cpc_probe};
+
+#undef NEXT_DEV
+#define NEXT_DEV (&cpc_dev)
+#endif

#ifdef CONFIG_NET_SB1000
extern int sb1000_probe(struct device *dev);

NOTE: this device (cpc) is just a "hook", as it will be removed from the
device chain as soon as the driver runs.

- Create a new function in linux/drivers/net/pc300.c , called cpc_probe:

__initfunc(int
cpc_probe (struct device *dev))
{
(void)cpc_init();
return (-1);
}

NOTES:
- the argument passed to the function is totally ignored (as suggested by
Alan Cox);
- cpc_init() is the function that detects the boards and initializes the
network devices (cpc0, cpc1, etc.);
- cpc_probe returns -1 so that the invalid and useless device "cpc" is
removed from the device chain.

This solution compiles fine, but there is a problem. The driver is
loaded, but I get the following warning msgs:

Cyclades-PC300 driver X.Y.Z.W YYYY/MM/DD
PC300/RSV #1: 256KB of RAM at 0xc2804000, IRQ9, 1 channel(s).
PC300/RSV #2: 256KB of RAM at 0xc2889000, IRQ9, 2 channel(s).
** Found a total of 2 board(s).
early initialization of device cpc0 is deferred <<<<--------\
early initialization of device cpc1 is deferred <<<<--------- HERE !!
early initialization of device cpc2 is deferred <<<<--------/
** Registered devices (card,channel): cpc0(1,0) cpc1(2,0) cpc2(2,1)

As a result, the devices do NOT work, i.e., I can put the interface up and
transmit packets, the packets go back through the line but not through the
Linux net interface.

If I load the same driver as a module, the msgs are NOT printed and the
devices work fine.

I know that the function printing this msg is register_netdevice(dev), in
linux/net/core/dev.c , but I don't know how to fix the problem (which I
assume to be in my driver).

Does anyone have any suggestions ?!?!?

If you need to have a look at the driver src, just let me know (I didn't
want to send it to the list to avoid unnecessary traffic).

Thanks in advance for your help.

Regards,
Ivan

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