diff options
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r-- | drivers/pci/pci-driver.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index f9a0aec3abcf..8a6f797de8e5 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -289,8 +289,26 @@ struct drv_dev_and_id { | |||
289 | static long local_pci_probe(void *_ddi) | 289 | static long local_pci_probe(void *_ddi) |
290 | { | 290 | { |
291 | struct drv_dev_and_id *ddi = _ddi; | 291 | struct drv_dev_and_id *ddi = _ddi; |
292 | 292 | struct device *dev = &ddi->dev->dev; | |
293 | return ddi->drv->probe(ddi->dev, ddi->id); | 293 | int rc; |
294 | |||
295 | /* Unbound PCI devices are always set to disabled and suspended. | ||
296 | * During probe, the device is set to enabled and active and the | ||
297 | * usage count is incremented. If the driver supports runtime PM, | ||
298 | * it should call pm_runtime_put_noidle() in its probe routine and | ||
299 | * pm_runtime_get_noresume() in its remove routine. | ||
300 | */ | ||
301 | pm_runtime_get_noresume(dev); | ||
302 | pm_runtime_set_active(dev); | ||
303 | pm_runtime_enable(dev); | ||
304 | |||
305 | rc = ddi->drv->probe(ddi->dev, ddi->id); | ||
306 | if (rc) { | ||
307 | pm_runtime_disable(dev); | ||
308 | pm_runtime_set_suspended(dev); | ||
309 | pm_runtime_put_noidle(dev); | ||
310 | } | ||
311 | return rc; | ||
294 | } | 312 | } |
295 | 313 | ||
296 | static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, | 314 | static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, |
@@ -369,11 +387,19 @@ static int pci_device_remove(struct device * dev) | |||
369 | struct pci_driver * drv = pci_dev->driver; | 387 | struct pci_driver * drv = pci_dev->driver; |
370 | 388 | ||
371 | if (drv) { | 389 | if (drv) { |
372 | if (drv->remove) | 390 | if (drv->remove) { |
391 | pm_runtime_get_sync(dev); | ||
373 | drv->remove(pci_dev); | 392 | drv->remove(pci_dev); |
393 | pm_runtime_put_noidle(dev); | ||
394 | } | ||
374 | pci_dev->driver = NULL; | 395 | pci_dev->driver = NULL; |
375 | } | 396 | } |
376 | 397 | ||
398 | /* Undo the runtime PM settings in local_pci_probe() */ | ||
399 | pm_runtime_disable(dev); | ||
400 | pm_runtime_set_suspended(dev); | ||
401 | pm_runtime_put_noidle(dev); | ||
402 | |||
377 | /* | 403 | /* |
378 | * If the device is still on, set the power state as "unknown", | 404 | * If the device is still on, set the power state as "unknown", |
379 | * since it might change by the next time we load the driver. | 405 | * since it might change by the next time we load the driver. |