On Mon, Oct 16, 2000 at 02:34:44AM -0400, Jeff Garzik wrote:
> 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 ();
> 

Looks like init_etherdev() calls can be safely removed or replaced by BUG()'s
(at least for ISA NIC drivers). Anybody have any objections ?

> 
> > 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;
>       }
> 

As far as I can remember, I did not see such checks in NIC drivers :(

> -- 
> 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 [EMAIL PROTECTED]
> Please read the FAQ at http://www.tux.org/lkml/

Best regards,
            Andrey
-- 
Andrey Panin            | Embedded systems software engineer
[EMAIL PROTECTED]        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to