Skip to contentSkip to conversation

spi: sh-msiof: Add spi_master_suspend/spi_master_resume

PATCH In review Ulrich Hecht 3 participants 3 messages Apr 13, 2018 – Apr 16, 2018 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: sh-msiof: Add spi_master_suspend/spi_master_resume

From: Gaku Inami <[email protected]>

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

[uli: simplified code, added pm field to platform driver]

---
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(+)
drivers/spi/spi-sh-msiof.c +23 -0
index ae086aa..db30aad 100644
@@ -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),
 	},
 };
Signature · 1 line
2.7.4
#1 lore raw

Review

Quoted 2 lines
(quoted diff) +2 -0
+	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);

Reviewed-by
#2 lore raw
Quoted 4 lines · Wolfram Sang

Review

Quoted 2 lines
(quoted diff) +2 -0
+     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:

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds