17
17
#include <linux/mod_devicetable.h>
18
18
#include <linux/of.h>
19
19
#include <linux/platform_device.h>
20
+ #include <linux/pm.h>
21
+ #include <linux/pm_runtime.h>
20
22
#include <linux/property.h>
21
23
#include <linux/slab.h>
22
24
#include <linux/spinlock.h>
@@ -431,30 +433,28 @@ static void mpc8xxx_remove(struct platform_device *pdev)
431
433
}
432
434
}
433
435
434
- #ifdef CONFIG_PM
435
- static int mpc8xxx_suspend (struct platform_device * pdev , pm_message_t state )
436
+ static int mpc8xxx_suspend (struct device * dev )
436
437
{
437
- struct mpc8xxx_gpio_chip * mpc8xxx_gc = platform_get_drvdata ( pdev );
438
+ struct mpc8xxx_gpio_chip * mpc8xxx_gc = dev_get_drvdata ( dev );
438
439
439
- if (mpc8xxx_gc -> irqn && device_may_wakeup (& pdev -> dev ))
440
+ if (mpc8xxx_gc -> irqn && device_may_wakeup (dev ))
440
441
enable_irq_wake (mpc8xxx_gc -> irqn );
441
442
442
443
return 0 ;
443
444
}
444
445
445
- static int mpc8xxx_resume (struct platform_device * pdev )
446
+ static int mpc8xxx_resume (struct device * dev )
446
447
{
447
- struct mpc8xxx_gpio_chip * mpc8xxx_gc = platform_get_drvdata ( pdev );
448
+ struct mpc8xxx_gpio_chip * mpc8xxx_gc = dev_get_drvdata ( dev );
448
449
449
- if (mpc8xxx_gc -> irqn && device_may_wakeup (& pdev -> dev ))
450
+ if (mpc8xxx_gc -> irqn && device_may_wakeup (dev ))
450
451
disable_irq_wake (mpc8xxx_gc -> irqn );
451
452
452
453
return 0 ;
453
454
}
454
- #else
455
- #define mpc8xxx_suspend NULL
456
- #define mpc8xxx_resume NULL
457
- #endif
455
+
456
+ static DEFINE_RUNTIME_DEV_PM_OPS (mpc8xx_pm_ops ,
457
+ mpc8xxx_suspend , mpc8xxx_resume , NULL) ;
458
458
459
459
#ifdef CONFIG_ACPI
460
460
static const struct acpi_device_id gpio_acpi_ids [] = {
@@ -467,12 +467,11 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
467
467
static struct platform_driver mpc8xxx_plat_driver = {
468
468
.probe = mpc8xxx_probe ,
469
469
.remove_new = mpc8xxx_remove ,
470
- .suspend = mpc8xxx_suspend ,
471
- .resume = mpc8xxx_resume ,
472
470
.driver = {
473
471
.name = "gpio-mpc8xxx" ,
474
472
.of_match_table = mpc8xxx_gpio_ids ,
475
473
.acpi_match_table = ACPI_PTR (gpio_acpi_ids ),
474
+ .pm = pm_ptr (& mpc8xx_pm_ops ),
476
475
},
477
476
};
478
477
0 commit comments