backlight: ld9040: convert ld9040 to dev_pm_ops
authorJingoo Han <jg1.han@samsung.com>
Mon, 29 Apr 2013 23:17:35 +0000 (16:17 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 30 Apr 2013 01:28:15 +0000 (18:28 -0700)
Instead of using legacy suspend/resume methods, using newer dev_pm_ops
structure allows better control over power management.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/video/backlight/ld9040.c

index 1b642f5f381a2d448fc63418063032b5f23756d2..1e0a3093ce5075198f73a17659bc9f6af33621ad 100644 (file)
@@ -775,12 +775,12 @@ static int ld9040_remove(struct spi_device *spi)
        return 0;
 }
 
-#if defined(CONFIG_PM)
-static int ld9040_suspend(struct spi_device *spi, pm_message_t mesg)
+#ifdef CONFIG_PM_SLEEP
+static int ld9040_suspend(struct device *dev)
 {
-       struct ld9040 *lcd = spi_get_drvdata(spi);
+       struct ld9040 *lcd = dev_get_drvdata(dev);
 
-       dev_dbg(&spi->dev, "lcd->power = %d\n", lcd->power);
+       dev_dbg(dev, "lcd->power = %d\n", lcd->power);
 
        /*
         * when lcd panel is suspend, lcd panel becomes off
@@ -789,19 +789,18 @@ static int ld9040_suspend(struct spi_device *spi, pm_message_t mesg)
        return ld9040_power(lcd, FB_BLANK_POWERDOWN);
 }
 
-static int ld9040_resume(struct spi_device *spi)
+static int ld9040_resume(struct device *dev)
 {
-       struct ld9040 *lcd = spi_get_drvdata(spi);
+       struct ld9040 *lcd = dev_get_drvdata(dev);
 
        lcd->power = FB_BLANK_POWERDOWN;
 
        return ld9040_power(lcd, FB_BLANK_UNBLANK);
 }
-#else
-#define ld9040_suspend         NULL
-#define ld9040_resume          NULL
 #endif
 
+static SIMPLE_DEV_PM_OPS(ld9040_pm_ops, ld9040_suspend, ld9040_resume);
+
 /* Power down all displays on reboot, poweroff or halt. */
 static void ld9040_shutdown(struct spi_device *spi)
 {
@@ -814,12 +813,11 @@ static struct spi_driver ld9040_driver = {
        .driver = {
                .name   = "ld9040",
                .owner  = THIS_MODULE,
+               .pm     = &ld9040_pm_ops,
        },
        .probe          = ld9040_probe,
        .remove         = ld9040_remove,
        .shutdown       = ld9040_shutdown,
-       .suspend        = ld9040_suspend,
-       .resume         = ld9040_resume,
 };
 
 module_spi_driver(ld9040_driver);