Skip to content

Commit 6b5e97c

Browse files
author
Bartosz Golaszewski
committed
gpio: mpc8xxx: switch to using DEFINE_RUNTIME_DEV_PM_OPS()
Use the preferred API for assigning system sleep pm callbacks in drivers. Suggested-by: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 4e26dda commit 6b5e97c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/gpio/gpio-mpc8xxx.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
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
460460
static const struct acpi_device_id gpio_acpi_ids[] = {
@@ -467,12 +467,11 @@ MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids);
467467
static 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

Comments
 (0)