提交 f92d74c1 编写于 作者: S Stephen M. Cameron 提交者: Bjorn Helgaas

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 f3ec4f87 ("PCI: change device runtime PM settings for probe
and remove") and 967577b0 ("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: NStephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
上级 fbeeb822
......@@ -264,11 +264,19 @@ static long local_pci_probe(void *_ddi)
pm_runtime_get_sync(dev);
pci_dev->driver = pci_drv;
rc = pci_drv->probe(pci_dev, ddi->id);
if (rc) {
if (!rc)
return rc;
if (rc < 0) {
pci_dev->driver = NULL;
pm_runtime_put_sync(dev);
return rc;
}
return rc;
/*
* Probe function should return < 0 for failure, 0 for success
* Treat values > 0 as success, but warn.
*/
dev_warn(dev, "Driver probe function unexpectedly returned %d\n", rc);
return 0;
}
static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册