Skip to content

Commit 2557b1f

Browse files
xhackerustcBartosz Golaszewski
authored andcommitted
gpio: htc-egpio: Use modern PM macros
Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards. This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch. Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Link: https://lore.kernel.org/r/20251124002105.25429-4-jszhang@kernel.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 56f3a6d commit 2557b1f

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

drivers/gpio/gpio-htc-egpio.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,41 +364,36 @@ static int __init egpio_probe(struct platform_device *pdev)
364364
return 0;
365365
}
366366

367-
#ifdef CONFIG_PM
368-
static int egpio_suspend(struct platform_device *pdev, pm_message_t state)
367+
static int egpio_suspend(struct device *dev)
369368
{
370-
struct egpio_info *ei = platform_get_drvdata(pdev);
369+
struct egpio_info *ei = dev_get_drvdata(dev);
371370

372-
if (ei->chained_irq && device_may_wakeup(&pdev->dev))
371+
if (ei->chained_irq && device_may_wakeup(dev))
373372
enable_irq_wake(ei->chained_irq);
374373
return 0;
375374
}
376375

377-
static int egpio_resume(struct platform_device *pdev)
376+
static int egpio_resume(struct device *dev)
378377
{
379-
struct egpio_info *ei = platform_get_drvdata(pdev);
378+
struct egpio_info *ei = dev_get_drvdata(dev);
380379

381-
if (ei->chained_irq && device_may_wakeup(&pdev->dev))
380+
if (ei->chained_irq && device_may_wakeup(dev))
382381
disable_irq_wake(ei->chained_irq);
383382

384383
/* Update registers from the cache, in case
385384
the CPLD was powered off during suspend */
386385
egpio_write_cache(ei);
387386
return 0;
388387
}
389-
#else
390-
#define egpio_suspend NULL
391-
#define egpio_resume NULL
392-
#endif
393388

389+
static DEFINE_SIMPLE_DEV_PM_OPS(egpio_pm_ops, egpio_suspend, egpio_resume);
394390

395391
static struct platform_driver egpio_driver = {
396392
.driver = {
397393
.name = "htc-egpio",
398394
.suppress_bind_attrs = true,
395+
.pm = pm_sleep_ptr(&egpio_pm_ops),
399396
},
400-
.suspend = egpio_suspend,
401-
.resume = egpio_resume,
402397
};
403398

404399
static int __init egpio_init(void)

0 commit comments

Comments
 (0)