1717#include <linux/mod_devicetable.h>
1818#include <linux/of.h>
1919#include <linux/platform_device.h>
20+ #include <linux/pm.h>
21+ #include <linux/pm_runtime.h>
2022#include <linux/property.h>
2123#include <linux/slab.h>
2224#include <linux/spinlock.h>
@@ -431,30 +433,28 @@ static void mpc8xxx_remove(struct platform_device *pdev)
431433 }
432434}
433435
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 )
436437{
437- struct mpc8xxx_gpio_chip * mpc8xxx_gc = platform_get_drvdata ( pdev );
438+ struct mpc8xxx_gpio_chip * mpc8xxx_gc = dev_get_drvdata ( dev );
438439
439- if (mpc8xxx_gc -> irqn && device_may_wakeup (& pdev -> dev ))
440+ if (mpc8xxx_gc -> irqn && device_may_wakeup (dev ))
440441 enable_irq_wake (mpc8xxx_gc -> irqn );
441442
442443 return 0 ;
443444}
444445
445- static int mpc8xxx_resume (struct platform_device * pdev )
446+ static int mpc8xxx_resume (struct device * dev )
446447{
447- struct mpc8xxx_gpio_chip * mpc8xxx_gc = platform_get_drvdata ( pdev );
448+ struct mpc8xxx_gpio_chip * mpc8xxx_gc = dev_get_drvdata ( dev );
448449
449- if (mpc8xxx_gc -> irqn && device_may_wakeup (& pdev -> dev ))
450+ if (mpc8xxx_gc -> irqn && device_may_wakeup (dev ))
450451 disable_irq_wake (mpc8xxx_gc -> irqn );
451452
452453 return 0 ;
453454}
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) ;
458458
459459#ifdef CONFIG_ACPI
460460static const struct acpi_device_id gpio_acpi_ids [] = {
@@ -467,12 +467,11 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
467467static struct platform_driver mpc8xxx_plat_driver = {
468468 .probe = mpc8xxx_probe ,
469469 .remove_new = mpc8xxx_remove ,
470- .suspend = mpc8xxx_suspend ,
471- .resume = mpc8xxx_resume ,
472470 .driver = {
473471 .name = "gpio-mpc8xxx" ,
474472 .of_match_table = mpc8xxx_gpio_ids ,
475473 .acpi_match_table = ACPI_PTR (gpio_acpi_ids ),
474+ .pm = pm_ptr (& mpc8xx_pm_ops ),
476475 },
477476};
478477
0 commit comments