Re: [Q] init_etherdev()

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Mon Oct 16 2000 - 01:34:44 EST


Andrey Panin wrote:
>
> Hi all,
>
> after walking through some of NIC drivers and trying to remove check_region()
> calls, i have two small questions:
>
> 1) many NIC drivers contain (in XXX_probe1 functions) check like this:
>
> if (dev == NULL) {
> dev = init_etherdev();
> }
>
> but many drivers don't check (dev == NULL) at all. So first question: is this check
> and init_etherdev() call really required or this is old crap waiting for removal ?

Look at the call paths for the drivers coming from Space.c... Most of
the NIC drivers that do the above are ISA drivers, where they are always
provided a device struct. I believe that we can change the above to

        if (dev == NULL)
                BUG ();

> 2) if init_etherdev() is required, than call to unregister_netdevice() is
> required too (in case of probe failure), isn't it ?

I think so.. I do know that if init_etherdev() is required, you must
also kfree() in the module_exit() function. Since this case is so rare
(AFAICS), most drivers don't handle this case, and never call kfree at
all.

-If- init_etherdev is required at all (I think it is not), then you
would need a flag... You would need two flags, if you want to handle
the case where dev->priv is allocated manually, versus allocated in
init_etherdev.

        if (dev == NULL) {
                dev = init_etherdev (0, 0);
                if (!dev) return -ENOMEM;
                tp->have_dynamic_netdev = 1;
        }

-- 
Jeff Garzik                    | The difference between laziness and
Building 1024                  | prioritization is the end result.
MandrakeSoft                   |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:08 EST