diff mbox

spi: sh-msiof: Add spi_master_suspend/spi_master_resume

Message ID 1523638908-21924-1-git-send-email-ulrich.hecht+renesas@gmail.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Ulrich Hecht April 13, 2018, 5:01 p.m. UTC
From: Gaku Inami <gaku.inami.xw@bp.renesas.com>

Add spi_master_suspend(), spi_master_resume() in PM callback since it needs
to start/stop the queue during suspend/resume.

Signed-off-by: Gaku Inami <gaku.inami.xw@bp.renesas.com>
Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com>
[uli: simplified code, added pm field to platform driver]
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
Slightly brushed up port from the BSP; tested to execute on suspend/resume
without breaking anything.

CU
Uli

 drivers/spi/spi-sh-msiof.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Wolfram Sang April 13, 2018, 5:28 p.m. UTC | #1
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);

struct sh_msiof_spi_priv *p = dev_get_drvdata(dev);
Geert Uytterhoeven April 16, 2018, 8:01 a.m. UTC | #2
On Fri, Apr 13, 2018 at 7:28 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>> +     struct platform_device *pdev = to_platform_device(dev);
>> +     struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
>
> struct sh_msiof_spi_priv *p = dev_get_drvdata(dev);

With Wolfram's comment taken into account:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox

Patch

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index ae086aa..db30aad 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1415,12 +1415,35 @@  static const struct platform_device_id spi_driver_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, spi_driver_ids);
 
+#ifdef CONFIG_PM_SLEEP
+static int sh_msiof_spi_suspend(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
+
+	return spi_master_suspend(p->master);
+}
+
+static int sh_msiof_spi_resume(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
+
+	return spi_master_resume(p->master);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops,
+			 sh_msiof_spi_suspend,
+			 sh_msiof_spi_resume);
+
 static struct platform_driver sh_msiof_spi_drv = {
 	.probe		= sh_msiof_spi_probe,
 	.remove		= sh_msiof_spi_remove,
 	.id_table	= spi_driver_ids,
 	.driver		= {
 		.name		= "spi_sh_msiof",
+		.pm		= &sh_msiof_spi_pm_ops,
 		.of_match_table = of_match_ptr(sh_msiof_match),
 	},
 };