Re: Dummy driver broken in pre-2.0.5

Nick Holloway (Nick.Holloway@alfie.demon.co.uk)
19 May 1996 10:33:53 +0100


Daniel Barlow <dan@detached.demon.co.uk> writes:
> You'll probably get two hundred reports of this, all from `demon'
> addresses. But here's mine anyway ...
>
> The change to net/core/dev.c
>
> * Thomas Bogendoerfer : Return ENODEV for dev_open, if there
> * is no device open function.
>
> breaks the dummy device; unless it is compiled as a module, it has no
> device open function.

I like it when people discover problems before I do -- it saves me
having to work out the answers (I'm currently downloading pre2.0.5, so
haven't hit it yet).

The change to net/core/dev.c means that dev_open is no longer optional --
it has to be provided.

I don't really understand the change. The _fops operations are ones
that are often called to override the defaults. In the case of the dummy
driver, there is nothing that needs to be done, so no routine is provided.
All it will help is catching one aspect of incorrect drivers (one that
need an open routine, but do not provide one).

If this change is needed, I think I would do the patch differently.
I would remove the "#ifdef MODULE" from around the definitions and use
of dev_open and dev_close, and leave the module stuff to do appropriate
things with MOD_{INC,DEC}_USE_COUNT (make them into a noop).

This is really up to Alan, since he did the modularisation of
the dummy driver (and will know why dev_open being mandatory is a
good/bad/indifferent idea).

[The sharp people amongst you will realise that this patch is against
1.2.13, but it was to hand, and this is more to illustrate what I mean]

--- /usr/src/linux/drivers/net/dummy.c Mon Jan 23 08:38:28 1995
+++ dummy.c Sun May 19 10:23:42 1996
@@ -61,7 +61,6 @@
static struct enet_statistics *dummy_get_stats(struct device *dev);
#endif

-#ifdef MODULE
static int dummy_open(struct device *dev)
{
MOD_INC_USE_COUNT;
@@ -74,9 +73,6 @@
return 0;
}

-#endif
-
-
int dummy_init(struct device *dev)
{
/* I commented this out as bootup is noisy enough anyway and this driver
@@ -91,10 +87,8 @@
memset(dev->priv, 0, sizeof(struct enet_statistics));
dev->get_stats = dummy_get_stats;
#endif
-#ifdef MODULE
dev->open = &dummy_open;
dev->stop = &dummy_close;
-#endif

/* Fill in the fields of the device structure with ethernet-generic values. */
ether_setup(dev);

-- 
 `O O'  | Home: Nick.Holloway@alfie.demon.co.uk
// ^ \\ | Work: Nick.Holloway@parallax.co.uk  http://www.parallax.co.uk/~alfie/