Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17c2dae3 authored by Lennert Buytenhek's avatar Lennert Buytenhek Committed by David Woodhouse
Browse files

[MTD] physmap: add power management support



Implement PM handling for physmap.  Idea from Steven Scholz, patch
by David Anders.

Signed-off-by: default avatarLennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 25f0c659
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -158,9 +158,42 @@ static int physmap_flash_probe(struct platform_device *dev)
	return err;
}

#ifdef CONFIG_PM
static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state)
{
	struct physmap_flash_info *info = platform_get_drvdata(dev);
	int ret = 0;

	if (info)
		ret = info->mtd->suspend(info->mtd);

	return ret;
}

static int physmap_flash_resume(struct platform_device *dev)
{
	struct physmap_flash_info *info = platform_get_drvdata(dev);
	if (info)
		info->mtd->resume(info->mtd);
	return 0;
}

static void physmap_flash_shutdown(struct platform_device *dev)
{
	struct physmap_flash_info *info = platform_get_drvdata(dev);
	if (info && info->mtd->suspend(info->mtd) == 0)
		info->mtd->resume(info->mtd);
}
#endif

static struct platform_driver physmap_flash_driver = {
	.probe		= physmap_flash_probe,
	.remove		= physmap_flash_remove,
#ifdef CONFIG_PM
	.suspend	= physmap_flash_suspend,
	.resume		= physmap_flash_resume,
	.shutdown	= physmap_flash_shutdown,
#endif
	.driver		= {
		.name	= "physmap-flash",
	},