Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207992
b: refs/heads/master
c: 057c58b
h: refs/heads/master
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Aug 10, 2010
1 parent 8190ea8 commit 9b72845
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2138a1f1835274b1d131a1aafa1655f60b2af122
refs/heads/master: 057c58bfb1dc9bbb75b8ba3b6c6336cfca63b9d0
77 changes: 39 additions & 38 deletions trunk/drivers/usb/core/hcd-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,43 @@ static int hcd_pci_suspend(struct device *dev)
return retval;
}

static int resume_common(struct device *dev, int event)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
int retval;

if (hcd->state != HC_STATE_SUSPENDED) {
dev_dbg(dev, "can't resume, not suspended!\n");
return 0;
}

retval = pci_enable_device(pci_dev);
if (retval < 0) {
dev_err(dev, "can't re-enable after resume, %d!\n", retval);
return retval;
}

pci_set_master(pci_dev);

clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);

if (hcd->driver->pci_resume) {
/* This call should be made only during system resume,
* not during runtime resume.
*/
wait_for_companions(pci_dev, hcd);

retval = hcd->driver->pci_resume(hcd,
event == PM_EVENT_RESTORE);
if (retval) {
dev_err(dev, "PCI post-resume error %d!\n", retval);
usb_hc_died(hcd);
}
}
return retval;
}

static int hcd_pci_suspend_noirq(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
Expand Down Expand Up @@ -452,50 +489,14 @@ static int hcd_pci_resume_noirq(struct device *dev)
return 0;
}

static int resume_common(struct device *dev, bool hibernated)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
struct usb_hcd *hcd = pci_get_drvdata(pci_dev);
int retval;

if (hcd->state != HC_STATE_SUSPENDED) {
dev_dbg(dev, "can't resume, not suspended!\n");
return 0;
}

retval = pci_enable_device(pci_dev);
if (retval < 0) {
dev_err(dev, "can't re-enable after resume, %d!\n", retval);
return retval;
}

pci_set_master(pci_dev);

clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);

if (hcd->driver->pci_resume) {
/* This call should be made only during system resume,
* not during runtime resume.
*/
wait_for_companions(pci_dev, hcd);

retval = hcd->driver->pci_resume(hcd, hibernated);
if (retval) {
dev_err(dev, "PCI post-resume error %d!\n", retval);
usb_hc_died(hcd);
}
}
return retval;
}

static int hcd_pci_resume(struct device *dev)
{
return resume_common(dev, false);
return resume_common(dev, PM_EVENT_RESUME);
}

static int hcd_pci_restore(struct device *dev)
{
return resume_common(dev, true);
return resume_common(dev, PM_EVENT_RESTORE);
}

const struct dev_pm_ops usb_hcd_pci_pm_ops = {
Expand Down

0 comments on commit 9b72845

Please sign in to comment.