aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2013-11-01 15:34:55 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-11-06 18:08:17 -0500
commitf92d74c1f5afaff7cd1ea14ade8f1ba6b519e422 (patch)
tree406dec41eebbb8f241bef2437e9c5765e65e45e6
parentfbeeb822f6f45cadf154d7b7cff1c13537cd799d (diff)
PCI: Warn on driver probe return value greater than zero
Ages ago, drivers could return values greater than zero from their probe function and this would be regarded as success. But after f3ec4f87d607 ("PCI: change device runtime PM settings for probe and remove") and 967577b06241 ("PCI/PM: Keep runtime PM enabled for unbound PCI devices"), we set dev->driver to NULL if the driver's probe function returns a value greater than zero. __pci_device_probe() treats this as success, and drivers can still mostly work even with dev->driver == NULL, but PCI power management doesn't work, and we don't call the driver's remove function on rmmod. To help catch these driver problems, issue a warning in this case. [bhelgaas: changelog] Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/pci-driver.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index b60fe6737f78..0929ae3e7830 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -264,11 +264,19 @@ static long local_pci_probe(void *_ddi)
264 pm_runtime_get_sync(dev); 264 pm_runtime_get_sync(dev);
265 pci_dev->driver = pci_drv; 265 pci_dev->driver = pci_drv;
266 rc = pci_drv->probe(pci_dev, ddi->id); 266 rc = pci_drv->probe(pci_dev, ddi->id);
267 if (rc) { 267 if (!rc)
268 return rc;
269 if (rc < 0) {
268 pci_dev->driver = NULL; 270 pci_dev->driver = NULL;
269 pm_runtime_put_sync(dev); 271 pm_runtime_put_sync(dev);
272 return rc;
270 } 273 }
271 return rc; 274 /*
275 * Probe function should return < 0 for failure, 0 for success
276 * Treat values > 0 as success, but warn.
277 */
278 dev_warn(dev, "Driver probe function unexpectedly returned %d\n", rc);
279 return 0;
272} 280}
273 281
274static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, 282static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,