Re: [PATCH] cpqarray update

From: Jeff Garzik
Date: Wed Jan 28 2004 - 18:42:05 EST


Hollis Blanchard wrote:
I'm defining a new bus and had copied pci_module_init() to vio_module_init(). Here's what Greg KH had to say about that:

Eeek! I want to fix that code in pci_module_init() so it doesn't do
this at all. Please don't copy that horrible function. Just register
the driver with a call to vio_register_driver() and drop the whole
vio_module_init() completly. I'll be doing that for pci soon, and
there's no reason you want to duplicate this broken logic (you always
want your module probe to succeed, for lots of reasons...)


Actually I disagree with GregKH on this.

The register/unregister functions need to be returning error codes, _not_ the count of interfaces registered. It is trivial to count the registered interfaces in the driver itself, but IMO far more important to propagate fatal errors back to the original caller.

This is what pci_module_init() does... returns an error if an error occurred, zero if not. Further, use of pci_module_init() makes drivers future-proof for a time when the API can better return fatal errors that occur during the registration process.

As it stands now, pci_register_driver() -can- call functions which can fail internally (see what driver_register calls...), unrelated to the driver, and the driver will never ever know this.

That is an ugly flaw in most current foo_register_driver() APIs. Errors are silently lost :(

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/