linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Jeff Garzik <jgarzik@pobox.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, Tejun Heo <tj@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: [PATCH v2 1/3] ahci: port legacy pm interface to struct dev_pm_ops
Date: Tue, 27 Dec 2011 13:42:32 +0800	[thread overview]
Message-ID: <1324964554-9719-2-git-send-email-ming.m.lin@intel.com> (raw)
In-Reply-To: <1324964554-9719-1-git-send-email-ming.m.lin@intel.com>

Also add hibernate callbacks.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
 drivers/ata/ahci.c |   48 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index cf26222..183c8b2 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -84,8 +84,10 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
 				unsigned long deadline);
 #ifdef CONFIG_PM
-static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
-static int ahci_pci_device_resume(struct pci_dev *pdev);
+static int ahci_pci_device_suspend(struct device *dev);
+static int ahci_pci_device_resume(struct device *dev);
+static int ahci_pci_device_freeze(struct device *dev);
+static int ahci_pci_device_poweroff(struct device *dev);
 #endif
 
 static struct scsi_host_template ahci_sht = {
@@ -400,6 +402,14 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 	{ }	/* terminate list */
 };
 
+static const struct dev_pm_ops ahci_pci_pm_ops = {
+	.suspend		= ahci_pci_device_suspend,
+	.resume			= ahci_pci_device_resume,
+	.freeze			= ahci_pci_device_freeze,
+	.thaw			= ahci_pci_device_resume,
+	.poweroff		= ahci_pci_device_poweroff,
+	.restore		= ahci_pci_device_resume,
+};
 
 static struct pci_driver ahci_pci_driver = {
 	.name			= DRV_NAME,
@@ -407,8 +417,9 @@ static struct pci_driver ahci_pci_driver = {
 	.probe			= ahci_init_one,
 	.remove			= ata_pci_remove_one,
 #ifdef CONFIG_PM
-	.suspend		= ahci_pci_device_suspend,
-	.resume			= ahci_pci_device_resume,
+	.driver			= {
+		.pm = &ahci_pci_pm_ops
+	},
 #endif
 };
 
@@ -567,7 +578,8 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
 }
 
 #ifdef CONFIG_PM
-static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
+static int ahci_pci_device_suspend_common(struct pci_dev *pdev,
+					  pm_message_t mesg)
 {
 	struct ata_host *host = dev_get_drvdata(&pdev->dev);
 	struct ahci_host_priv *hpriv = host->private_data;
@@ -595,9 +607,31 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 	return ata_pci_device_suspend(pdev, mesg);
 }
 
-static int ahci_pci_device_resume(struct pci_dev *pdev)
+static int ahci_pci_device_suspend(struct device *dev)
 {
-	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	return ahci_pci_device_suspend_common(pdev, PMSG_SUSPEND);
+}
+
+static int ahci_pci_device_freeze(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	return ahci_pci_device_suspend_common(pdev, PMSG_FREEZE);
+}
+
+static int ahci_pci_device_poweroff(struct device *dev)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	return ahci_pci_device_suspend_common(pdev, PMSG_HIBERNATE);
+}
+
+static int ahci_pci_device_resume(struct device *dev)
+{
+	struct ata_host *host = dev_get_drvdata(dev);
+	struct pci_dev *pdev = to_pci_dev(dev);
 	int rc;
 
 	rc = ata_pci_device_do_resume(pdev);
-- 
1.7.2.5


  reply	other threads:[~2011-12-27  5:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-27  5:42 [PATCH v2 0/3] ahci controller runtime PM support Lin Ming
2011-12-27  5:42 ` Lin Ming [this message]
2011-12-27  5:42 ` [PATCH v2 2/3] ahci: add runtime PM callbacks Lin Ming
2011-12-27  5:42 ` [PATCH v2 3/3] ata: runtime suspend port if no device attached Lin Ming
2012-01-13  2:17 ` [PATCH v2 0/3] ahci controller runtime PM support Lin Ming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1324964554-9719-2-git-send-email-ming.m.lin@intel.com \
    --to=ming.m.lin@intel.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).