Skip to content

Commit ffa69d6

Browse files
GakuInamibroonie
authored andcommitted
spi: sh-msiof: Fix invalid SPI use during system suspend
If the SPI queue is running during system suspend, the system may lock up. Fix this by stopping/restarting the queue during system suspend/resume by calling spi_master_suspend()/spi_master_resume() from the PM callbacks. In-kernel users will receive an -ESHUTDOWN error while system suspend/resume is in progress. Signed-off-by: Gaku Inami <gaku.inami.xw@bp.renesas.com> Signed-off-by: Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@renesas.com> [geert: Cleanup, reword] Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 1723c31 commit ffa69d6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,12 +1426,37 @@ static const struct platform_device_id spi_driver_ids[] = {
14261426
};
14271427
MODULE_DEVICE_TABLE(platform, spi_driver_ids);
14281428

1429+
#ifdef CONFIG_PM_SLEEP
1430+
static int sh_msiof_spi_suspend(struct device *dev)
1431+
{
1432+
struct platform_device *pdev = to_platform_device(dev);
1433+
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1434+
1435+
return spi_master_suspend(p->master);
1436+
}
1437+
1438+
static int sh_msiof_spi_resume(struct device *dev)
1439+
{
1440+
struct platform_device *pdev = to_platform_device(dev);
1441+
struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1442+
1443+
return spi_master_resume(p->master);
1444+
}
1445+
1446+
static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops, sh_msiof_spi_suspend,
1447+
sh_msiof_spi_resume);
1448+
#define DEV_PM_OPS &sh_msiof_spi_pm_ops
1449+
#else
1450+
#define DEV_PM_OPS NULL
1451+
#endif /* CONFIG_PM_SLEEP */
1452+
14291453
static struct platform_driver sh_msiof_spi_drv = {
14301454
.probe = sh_msiof_spi_probe,
14311455
.remove = sh_msiof_spi_remove,
14321456
.id_table = spi_driver_ids,
14331457
.driver = {
14341458
.name = "spi_sh_msiof",
1459+
.pm = DEV_PM_OPS,
14351460
.of_match_table = of_match_ptr(sh_msiof_match),
14361461
},
14371462
};

0 commit comments

Comments
 (0)