aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/hcd-pci.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-06-25 14:02:03 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-10 17:35:37 -0400
commit057c58bfb1dc9bbb75b8ba3b6c6336cfca63b9d0 (patch)
tree0271901d82af52ce38f6e65beaae565dadea5273 /drivers/usb/core/hcd-pci.c
parent2138a1f1835274b1d131a1aafa1655f60b2af122 (diff)
USB: move PCI HCD resume routine
This patch (as1384) moves the resume_common() routine in hcd-pci.c a little higher in the source file to avoid forward references in an upcoming patch. It also replaces the "hibernated" argument with a more general "event" argument, which will be useful when the routine is called during a runtime resume. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/hcd-pci.c')
-rw-r--r--drivers/usb/core/hcd-pci.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 7c3b0af6224..f0156de8db6 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -403,6 +403,43 @@ static int hcd_pci_suspend(struct device *dev)
403 return retval; 403 return retval;
404} 404}
405 405
406static int resume_common(struct device *dev, int event)
407{
408 struct pci_dev *pci_dev = to_pci_dev(dev);
409 struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
410 int retval;
411
412 if (hcd->state != HC_STATE_SUSPENDED) {
413 dev_dbg(dev, "can't resume, not suspended!\n");
414 return 0;
415 }
416
417 retval = pci_enable_device(pci_dev);
418 if (retval < 0) {
419 dev_err(dev, "can't re-enable after resume, %d!\n", retval);
420 return retval;
421 }
422
423 pci_set_master(pci_dev);
424
425 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
426
427 if (hcd->driver->pci_resume) {
428 /* This call should be made only during system resume,
429 * not during runtime resume.
430 */
431 wait_for_companions(pci_dev, hcd);
432
433 retval = hcd->driver->pci_resume(hcd,
434 event == PM_EVENT_RESTORE);
435 if (retval) {
436 dev_err(dev, "PCI post-resume error %d!\n", retval);
437 usb_hc_died(hcd);
438 }
439 }
440 return retval;
441}
442
406static int hcd_pci_suspend_noirq(struct device *dev) 443static int hcd_pci_suspend_noirq(struct device *dev)
407{ 444{
408 struct pci_dev *pci_dev = to_pci_dev(dev); 445 struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -452,50 +489,14 @@ static int hcd_pci_resume_noirq(struct device *dev)
452 return 0; 489 return 0;
453} 490}
454 491
455static int resume_common(struct device *dev, bool hibernated)
456{
457 struct pci_dev *pci_dev = to_pci_dev(dev);
458 struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
459 int retval;
460
461 if (hcd->state != HC_STATE_SUSPENDED) {
462 dev_dbg(dev, "can't resume, not suspended!\n");
463 return 0;
464 }
465
466 retval = pci_enable_device(pci_dev);
467 if (retval < 0) {
468 dev_err(dev, "can't re-enable after resume, %d!\n", retval);
469 return retval;
470 }
471
472 pci_set_master(pci_dev);
473
474 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
475
476 if (hcd->driver->pci_resume) {
477 /* This call should be made only during system resume,
478 * not during runtime resume.
479 */
480 wait_for_companions(pci_dev, hcd);
481
482 retval = hcd->driver->pci_resume(hcd, hibernated);
483 if (retval) {
484 dev_err(dev, "PCI post-resume error %d!\n", retval);
485 usb_hc_died(hcd);
486 }
487 }
488 return retval;
489}
490
491static int hcd_pci_resume(struct device *dev) 492static int hcd_pci_resume(struct device *dev)
492{ 493{
493 return resume_common(dev, false); 494 return resume_common(dev, PM_EVENT_RESUME);
494} 495}
495 496
496static int hcd_pci_restore(struct device *dev) 497static int hcd_pci_restore(struct device *dev)
497{ 498{
498 return resume_common(dev, true); 499 return resume_common(dev, PM_EVENT_RESTORE);
499} 500}
500 501
501const struct dev_pm_ops usb_hcd_pci_pm_ops = { 502const struct dev_pm_ops usb_hcd_pci_pm_ops = {