Patchwork [3/6] sata_mv: add power management support for the platform driver

login
register
mail settings
Submitter Saeed Bishara
Date Dec. 6, 2009, 4:26 p.m.
Message ID <1260116782-31714-3-git-send-email-saeed@marvell.com>
Download mbox | patch
Permalink /patch/40430/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Saeed Bishara - Dec. 6, 2009, 4:26 p.m.
Signed-off-by: Saeed Bishara <saeed@marvell.com>
---
 drivers/ata/sata_mv.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 drivers/ata/sata_mv.c
Grant Grundler - Dec. 7, 2009, 6:14 a.m.
On Sun, Dec 6, 2009 at 8:26 AM, Saeed Bishara <saeed@marvell.com> wrote:
> Signed-off-by: Saeed Bishara <saeed@marvell.com>
> ---
>  drivers/ata/sata_mv.c |   43 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 43 insertions(+), 0 deletions(-)
>  mode change 100644 => 100755 drivers/ata/sata_mv.c
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> old mode 100644
> new mode 100755
> index 0906df4..17a138b
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4112,9 +4112,52 @@ static int __devexit mv_platform_remove(struct platform_device *pdev)
>        return 0;
>  }
>
> +#ifdef CONFIG_PM
> +static int mv_platform_suspend(struct platform_device *pdev, pm_message_t state)
> +{
> +       struct ata_host *host = dev_get_drvdata(&pdev->dev);
> +       if (host)
> +               return ata_host_suspend(host, state);
> +       else
> +               return 0;

Just curious: Is this really enough?

Most drivers in drivers/ata/ are setting ata_pci_device_suspend() as
their .suspend function. This calls ata_host_suspend().

ata_piix seems to be the only driver that calls  ata_pci_device_do_suspend().

Please add "Reviewed-by: Grant Grundler <grundler@google.com>" once
the above is clarified.

thanks,
grant

> +}
> +
> +static int mv_platform_resume(struct platform_device *pdev)
> +{
> +       struct ata_host *host = dev_get_drvdata(&pdev->dev);
> +       int ret;
> +
> +       if (host) {
> +               struct mv_host_priv *hpriv = host->private_data;
> +               const struct mv_sata_platform_data *mv_platform_data = \
> +                       pdev->dev.platform_data;
> +               /*
> +                * (Re-)program MBUS remapping windows if we are asked to.
> +                */
> +               if (mv_platform_data->dram != NULL)
> +                       mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
> +
> +               /* initialize adapter */
> +               ret = mv_init_host(host, chip_soc);
> +               if (ret) {
> +                       printk(KERN_ERR DRV_NAME ": Error during HW init\n");
> +                       return ret;
> +               }
> +               ata_host_resume(host);
> +       }
> +
> +       return 0;
> +}
> +#else
> +#define mv_platform_suspend NULL
> +#define mv_platform_resume NULL
> +#endif
> +
>  static struct platform_driver mv_platform_driver = {
>        .probe                  = mv_platform_probe,
>        .remove                 = __devexit_p(mv_platform_remove),
> +       .suspend                = mv_platform_suspend,
> +       .resume                 = mv_platform_resume,
>        .driver                 = {
>                                   .name = DRV_NAME,
>                                   .owner = THIS_MODULE,
> --
> 1.6.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
old mode 100644
new mode 100755
index 0906df4..17a138b
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4112,9 +4112,52 @@  static int __devexit mv_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int mv_platform_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	if (host)
+		return ata_host_suspend(host, state);
+	else
+		return 0;
+}
+
+static int mv_platform_resume(struct platform_device *pdev)
+{
+	struct ata_host *host = dev_get_drvdata(&pdev->dev);
+	int ret;
+
+	if (host) {
+		struct mv_host_priv *hpriv = host->private_data;
+		const struct mv_sata_platform_data *mv_platform_data = \
+			pdev->dev.platform_data;
+		/*
+		 * (Re-)program MBUS remapping windows if we are asked to.
+		 */
+		if (mv_platform_data->dram != NULL)
+			mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
+
+		/* initialize adapter */
+		ret = mv_init_host(host, chip_soc);
+		if (ret) {
+			printk(KERN_ERR DRV_NAME ": Error during HW init\n");
+			return ret;
+		}
+		ata_host_resume(host);
+	}
+
+	return 0;
+}
+#else
+#define mv_platform_suspend NULL
+#define mv_platform_resume NULL
+#endif
+
 static struct platform_driver mv_platform_driver = {
 	.probe			= mv_platform_probe,
 	.remove			= __devexit_p(mv_platform_remove),
+	.suspend		= mv_platform_suspend,
+	.resume			= mv_platform_resume,
 	.driver			= {
 				   .name = DRV_NAME,
 				   .owner = THIS_MODULE,