Skip to content

Commit

Permalink
[pb] Add basic suspend/resume methods
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Oct 12, 2010
1 parent aece5cb commit 58be2f2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions kernel/pulseblaster.c
Expand Up @@ -559,6 +559,53 @@ static struct bin_attribute dev_attr_program = {
.write = pb_attr_program_write,
};

/*****************************************************************************
*
* Power management
*
*****************************************************************************
*/

/**
* Suspend device
*
* @pci: PCI device
* @state: Power state
*/
static int __maybe_unused pb_suspend(struct pci_dev *pci, pm_message_t state)
{
struct pulseblaster *pb = pci_get_drvdata(pci);

/* Prepare to suspend PCI device */
pci_save_state(pci);
pci_disable_device(pci);
pci_set_power_state(pci, pci_choose_state(pci, state));

/* Reset state that will be destroyed by powering off */
pb->offset = 0;

return 0;
}

/**
* Resume device
*
* @pci: PCI device
*/
static int __maybe_unused pb_resume(struct pci_dev *pci)
{
int rc;

/* Restore PCI device */
pci_set_power_state(pci, PCI_D0);
rc = pci_enable_device(pci);
if (rc)
return rc;
pci_restore_state(pci);

return 0;
}

/*****************************************************************************
*
* Device probe and remove
Expand Down Expand Up @@ -700,6 +747,10 @@ static struct pci_driver pb_pci_driver = {
.id_table = pb_pci_tbl,
.probe = pb_probe,
.remove = __devexit_p(pb_remove),
#ifdef CONFIG_PM
.suspend = pb_suspend,
.resume = pb_resume,
#endif /* CONFIG_PM */
};

/**
Expand Down

0 comments on commit 58be2f2

Please sign in to comment.