Re: [PATCH] ahci: platform support for suspend/resume

From: Felipe Balbi
Date: Wed Nov 16 2011 - 15:34:30 EST


On Wed, Nov 16, 2011 at 12:27:59PM -0800, Brian Norris wrote:
> Add platform hooks for custom suspend() and resume() functions. The
> generic suspend/resume code in drivers/ata/ahci_platform.c is adapted
> from the PCI version in drivers/ata/ahci.c.
>
> Note that in order to suspend, we require that both suspend() and
> resume() functions be supplied.
>
> Signed-off-by: Brian Norris <computersforpeace@xxxxxxxxx>
> ---
> Based on:
> git://github.com/jgarzik/libata-dev.git ALL
>
> drivers/ata/ahci_platform.c | 72 +++++++++++++++++++++++++++++++++++++++++
> include/linux/ahci_platform.h | 2 +
> 2 files changed, 74 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
> index ec55595..98bf5e9 100644
> --- a/drivers/ata/ahci_platform.c
> +++ b/drivers/ata/ahci_platform.c
> @@ -202,6 +202,75 @@ static int __devexit ahci_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM
> +static int ahci_suspend(struct device *dev)
> +{
> + struct ahci_platform_data *pdata = dev_get_platdata(dev);
> + struct ata_host *host = dev_get_drvdata(dev);
> + struct ahci_host_priv *hpriv = host->private_data;
> + void __iomem *mmio = hpriv->mmio;
> + u32 ctl;
> + int rc;
> +
> + /* Does platform support suspend/resume? */
> + if (!pdata->suspend || !pdata->resume)
> + return -EINVAL;

should you really prevent suspend is platform doesn't provide
->suspend() ?

I mean, we could some platform where all clocks are autogated and
there's no need for platform to do anything. Would it be better to only
call pdata->suspend if it exists but still let the AHCI-specific part go
through ?

--
balbi

Attachment: signature.asc
Description: Digital signature