aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaibhav Gupta <vaibhavgupta40@gmail.com>2020-07-13 23:06:12 +0530
committerDavid S. Miller <davem@davemloft.net>2020-08-03 18:48:46 -0700
commitf9e09a0711ca4ff7b689688936039772c24ea689 (patch)
tree32c5863cbb56252c0c759bcfe726a58901fb9a26
parent9a51ffe845e4bc8cf8f826139e894ee6353c60fe (diff)
downloadide-f9e09a0711ca4ff7b689688936039772c24ea689.tar.gz
ide: sc1200: use generic power management
With the support of generic PM callbacks, drivers no longer need to use legacy .suspend() and .resume() in which they had to maintain PCI states changes and device's power state themselves. The required operations are done by PCI core. Compile-tested only. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/ide/sc1200.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
index a5b701818405ba..91a197832d1f54 100644
--- a/drivers/ide/sc1200.c
+++ b/drivers/ide/sc1200.c
@@ -222,46 +222,33 @@ static void sc1200_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)
sc1200_tunepio(drive, pio);
}
-#ifdef CONFIG_PM
struct sc1200_saved_state {
u32 regs[8];
};
-static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
+static int __maybe_unused sc1200_suspend(struct device *dev_d)
{
- printk("SC1200: suspend(%u)\n", state.event);
+ struct pci_dev *dev = to_pci_dev(dev_d);
+ struct ide_host *host = pci_get_drvdata(dev);
+ struct sc1200_saved_state *ss = host->host_priv;
+ unsigned int r;
/*
- * we only save state when going from full power to less
+ * save timing registers
+ * (this may be unnecessary if BIOS also does it)
*/
- if (state.event == PM_EVENT_ON) {
- struct ide_host *host = pci_get_drvdata(dev);
- struct sc1200_saved_state *ss = host->host_priv;
- unsigned int r;
-
- /*
- * save timing registers
- * (this may be unnecessary if BIOS also does it)
- */
- for (r = 0; r < 8; r++)
- pci_read_config_dword(dev, 0x40 + r * 4, &ss->regs[r]);
- }
+ for (r = 0; r < 8; r++)
+ pci_read_config_dword(dev, 0x40 + r * 4, &ss->regs[r]);
- pci_disable_device(dev);
- pci_set_power_state(dev, pci_choose_state(dev, state));
return 0;
}
-static int sc1200_resume (struct pci_dev *dev)
+static int __maybe_unused sc1200_resume(struct device *dev_d)
{
+ struct pci_dev *dev = to_pci_dev(dev_d);
struct ide_host *host = pci_get_drvdata(dev);
struct sc1200_saved_state *ss = host->host_priv;
unsigned int r;
- int i;
-
- i = pci_enable_device(dev);
- if (i)
- return i;
/*
* restore timing registers
@@ -272,7 +259,6 @@ static int sc1200_resume (struct pci_dev *dev)
return 0;
}
-#endif
static const struct ide_port_ops sc1200_port_ops = {
.set_pio_mode = sc1200_set_pio_mode,
@@ -326,15 +312,14 @@ static const struct pci_device_id sc1200_pci_tbl[] = {
};
MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl);
+static SIMPLE_DEV_PM_OPS(sc1200_pm_ops, sc1200_suspend, sc1200_resume);
+
static struct pci_driver sc1200_pci_driver = {
.name = "SC1200_IDE",
.id_table = sc1200_pci_tbl,
.probe = sc1200_init_one,
.remove = ide_pci_remove,
-#ifdef CONFIG_PM
- .suspend = sc1200_suspend,
- .resume = sc1200_resume,
-#endif
+ .driver.pm = &sc1200_pm_ops,
};
static int __init sc1200_ide_init(void)