2022-04-26 05:44:11

by Liu Xinpeng

[permalink] [raw]
Subject: [PATCH v3 4/4] watchdog: iTCO_wdg: Make code more clearly with macro definition

Using SET_NOIRQ_SYSTEM_SLEEP_PM_OPS reduces redundant code.

Signed-off-by: Liu Xinpeng <[email protected]>
---
drivers/watchdog/iTCO_wdt.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 3f2f4343644f..f870cf08f143 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -596,7 +596,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
/*
* Suspend-to-idle requires this, because it stops the ticks and timekeeping, so
* the watchdog cannot be pinged while in that state. In ACPI sleep states the
@@ -637,20 +636,15 @@ static int iTCO_wdt_resume_noirq(struct device *dev)
}

static const struct dev_pm_ops iTCO_wdt_pm = {
- .suspend_noirq = iTCO_wdt_suspend_noirq,
- .resume_noirq = iTCO_wdt_resume_noirq,
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(iTCO_wdt_suspend_noirq,
+ iTCO_wdt_resume_noirq)
};

-#define ITCO_WDT_PM_OPS (&iTCO_wdt_pm)
-#else
-#define ITCO_WDT_PM_OPS NULL
-#endif /* CONFIG_PM_SLEEP */
-
static struct platform_driver iTCO_wdt_driver = {
.probe = iTCO_wdt_probe,
.driver = {
.name = DRV_NAME,
- .pm = ITCO_WDT_PM_OPS,
+ .pm = &iTCO_wdt_pm,
},
};

--
2.23.0


2022-04-26 09:13:43

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] watchdog: iTCO_wdg: Make code more clearly with macro definition

On Tue, Apr 26, 2022 at 11:35:20AM +0800, Liu Xinpeng wrote:
> @@ -596,7 +596,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
> return 0;
> }
>
> -#ifdef CONFIG_PM_SLEEP
> /*
> * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so
> * the watchdog cannot be pinged while in that state. In ACPI sleep states the
> @@ -637,20 +636,15 @@ static int iTCO_wdt_resume_noirq(struct device *dev)
> }
>
> static const struct dev_pm_ops iTCO_wdt_pm = {
> - .suspend_noirq = iTCO_wdt_suspend_noirq,
> - .resume_noirq = iTCO_wdt_resume_noirq,
> + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(iTCO_wdt_suspend_noirq,
> + iTCO_wdt_resume_noirq)

Thus, iTCO_wdt_suspend_noirq and iTCO_wdt_resume_noirq are possible unused.
Put __maybe_unused attribute to them.