Re: [PATCH] Handling failure of pci_register_driver().

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Sun Feb 20 2000 - 13:10:30 EST


> There's an issue with the new PCI register interface: a return value of 0
> from pci_register_driver() does _not_ indicate failed registration; the
> supplied pci_driver struct is linked in the pci_drivers list even if no
> matching PCI devices were found. This behaviour makes tons of sense when
> thinking of hot pluggable devices. Unfortunately every non-cardbus driver
> in 2.3.46 using pci_register_driver() gets it wrong and bails out from its
> module_init() routine immediately on a zero return value, leaving a stale
> entry in the pci_drivers list -> Oops... Instead, if a driver chooses to
> treat a zero return value from pci_register_driver() as an error in its
> init routine, it has to unregister the driver first. The patch below
> should fix the affected drivers as of kernel version 2.3.46.

Very good spotting. I have read the code for pci_[un]register_driver
several times, but this did not occur to me. However I do not agree
with the patch as presented...

This is what I have in 8139too now, before your bugfix...

/* module stays resident iff CONFIG_HOTPLUG and compiled into kernel */
#if !defined(CONFIG_HOTPLUG) || defined(MODULE)
        return (rc > 0) ? 0 : (rc == 0 ? -ENODEV : rc);
#else
        return (rc >= 0) ? 0 : rc;
#endif

Adding your bugfix to this junk will make things even uglier, so I think
that encapsulating all this behavior into a macro of some sort would be
good...

-- 
Jeff Garzik         | I never vote for anyone.
Building 1024       | I always vote against.
MandrakeSoft, Inc.  |       -- W.C. Fields

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



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:25 EST