mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
ahci: Convert driver to use modern PM hooks
In order to add support for runtime PM to the ahci driver we first need to convert the driver to use modern non-legacy system suspend hooks. There should be no functional changes. tj: Updated .driver.pm init for older compilers as suggested by Andy and Chrsitoph. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
8ea909cb35
commit
f1d848f9fb
1 changed files with 24 additions and 27 deletions
|
@ -93,9 +93,9 @@ static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
|
||||||
static bool is_mcp89_apple(struct pci_dev *pdev);
|
static bool is_mcp89_apple(struct pci_dev *pdev);
|
||||||
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
|
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
|
||||||
unsigned long deadline);
|
unsigned long deadline);
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM_SLEEP
|
||||||
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
|
static int ahci_pci_device_suspend(struct device *dev);
|
||||||
static int ahci_pci_device_resume(struct pci_dev *pdev);
|
static int ahci_pci_device_resume(struct device *dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct scsi_host_template ahci_sht = {
|
static struct scsi_host_template ahci_sht = {
|
||||||
|
@ -557,16 +557,18 @@ static const struct pci_device_id ahci_pci_tbl[] = {
|
||||||
{ } /* terminate list */
|
{ } /* terminate list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct dev_pm_ops ahci_pci_pm_ops = {
|
||||||
|
SET_SYSTEM_SLEEP_PM_OPS(ahci_pci_device_suspend, ahci_pci_device_resume)
|
||||||
|
};
|
||||||
|
|
||||||
static struct pci_driver ahci_pci_driver = {
|
static struct pci_driver ahci_pci_driver = {
|
||||||
.name = DRV_NAME,
|
.name = DRV_NAME,
|
||||||
.id_table = ahci_pci_tbl,
|
.id_table = ahci_pci_tbl,
|
||||||
.probe = ahci_init_one,
|
.probe = ahci_init_one,
|
||||||
.remove = ata_pci_remove_one,
|
.remove = ata_pci_remove_one,
|
||||||
#ifdef CONFIG_PM
|
.driver = {
|
||||||
.suspend = ahci_pci_device_suspend,
|
.pm = &ahci_pci_pm_ops,
|
||||||
.resume = ahci_pci_device_resume,
|
},
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
|
#if defined(CONFIG_PATA_MARVELL) || defined(CONFIG_PATA_MARVELL_MODULE)
|
||||||
|
@ -794,44 +796,39 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM_SLEEP
|
||||||
static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
|
static int ahci_pci_device_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct pci_dev *pdev = to_pci_dev(dev);
|
||||||
struct ata_host *host = pci_get_drvdata(pdev);
|
struct ata_host *host = pci_get_drvdata(pdev);
|
||||||
struct ahci_host_priv *hpriv = host->private_data;
|
struct ahci_host_priv *hpriv = host->private_data;
|
||||||
void __iomem *mmio = hpriv->mmio;
|
void __iomem *mmio = hpriv->mmio;
|
||||||
u32 ctl;
|
u32 ctl;
|
||||||
|
|
||||||
if (mesg.event & PM_EVENT_SUSPEND &&
|
if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
|
||||||
hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
|
|
||||||
dev_err(&pdev->dev,
|
dev_err(&pdev->dev,
|
||||||
"BIOS update required for suspend/resume\n");
|
"BIOS update required for suspend/resume\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesg.event & PM_EVENT_SLEEP) {
|
/* AHCI spec rev1.1 section 8.3.3:
|
||||||
/* AHCI spec rev1.1 section 8.3.3:
|
* Software must disable interrupts prior to requesting a
|
||||||
* Software must disable interrupts prior to requesting a
|
* transition of the HBA to D3 state.
|
||||||
* transition of the HBA to D3 state.
|
*/
|
||||||
*/
|
ctl = readl(mmio + HOST_CTL);
|
||||||
ctl = readl(mmio + HOST_CTL);
|
ctl &= ~HOST_IRQ_EN;
|
||||||
ctl &= ~HOST_IRQ_EN;
|
writel(ctl, mmio + HOST_CTL);
|
||||||
writel(ctl, mmio + HOST_CTL);
|
readl(mmio + HOST_CTL); /* flush */
|
||||||
readl(mmio + HOST_CTL); /* flush */
|
|
||||||
}
|
|
||||||
|
|
||||||
return ata_pci_device_suspend(pdev, mesg);
|
return ata_host_suspend(host, PMSG_SUSPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ahci_pci_device_resume(struct pci_dev *pdev)
|
static int ahci_pci_device_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct pci_dev *pdev = to_pci_dev(dev);
|
||||||
struct ata_host *host = pci_get_drvdata(pdev);
|
struct ata_host *host = pci_get_drvdata(pdev);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ata_pci_device_do_resume(pdev);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
/* Apple BIOS helpfully mangles the registers on resume */
|
/* Apple BIOS helpfully mangles the registers on resume */
|
||||||
if (is_mcp89_apple(pdev))
|
if (is_mcp89_apple(pdev))
|
||||||
ahci_mcp89_apple_enable(pdev);
|
ahci_mcp89_apple_enable(pdev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue