Hi,
I'm looking at why drivers test if they need to allocate a new dev in
the
probe routines, like ac3200_probe in the ac3200.c file, I understand that it is
assigned to dev->init and then called thru register_netdev, explicitly or thru
init_etherdev, when creating a new net_device; it can otherwise be called thru
net_dev_init in net/core/dev.c. In the second case (the ugly duck Space.c) the
dev parameter for the probe will always be non NULL. If it is called thru
register_netdev it will as well be non NULL, so the only case would be for in
the driver code the probe to called directly, passing NULL as the dev argument,
which is not the case, for example, of ac3200.c, so why check if dev == NULL?
Here is the excerpt:
/* We should have a "dev" from Space.c or the static module table. */
if (dev == NULL) {
printk("ac3200.c: Passed a NULL device.\n");
dev = init_etherdev(0, 0);
if (!dev)
return -ENOMEM;
}
there are other drivers with this kind of code, being paranoid? I think that we
may well do this:
if (dev == NULL)
panic();
8)
I'm completely wrong? If so, could any good soul just say something like:
"think about this ...", not that much, so that I can go ahead and try to help
in cleaning the drivers of what seems to be historic code not needed anymore.
If I'm right then now I know why all those drivers seems to not ever have
oopsed by not checking the init_etherdev results... it never was called in this
situation 8)
- Arnaldo
|