From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6331FEB64D9 for ; Fri, 7 Jul 2023 07:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbjGGHiH (ORCPT ); Fri, 7 Jul 2023 03:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbjGGHiF (ORCPT ); Fri, 7 Jul 2023 03:38:05 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E7619B2; Fri, 7 Jul 2023 00:38:02 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 5EDF124E1AC; Fri, 7 Jul 2023 15:37:48 +0800 (CST) Received: from EXMBX061.cuchost.com (172.16.6.61) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 7 Jul 2023 15:37:48 +0800 Received: from [192.168.125.128] (113.72.145.114) by EXMBX061.cuchost.com (172.16.6.61) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 7 Jul 2023 15:37:47 +0800 Message-ID: Date: Fri, 7 Jul 2023 15:34:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] watchdog: starfive: Remove #ifdef guards for PM related functions Content-Language: en-US To: Paul Cercueil CC: Samin Guo , Wim Van Sebroeck , Guenter Roeck , , References: <20230706082928.10869-1-paul@crapouillou.net> From: Xingyu Wu In-Reply-To: <20230706082928.10869-1-paul@crapouillou.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [113.72.145.114] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) To EXMBX061.cuchost.com (172.16.6.61) X-YovoleRuleAgent: yovoleflag Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/7/6 16:29, Paul Cercueil wrote: > Use the new 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: Paul Cercueil > --- > drivers/watchdog/starfive-wdt.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c > index 8058fca4d05d..7c8a1c5e75be 100644 > --- a/drivers/watchdog/starfive-wdt.c > +++ b/drivers/watchdog/starfive-wdt.c > @@ -526,7 +526,6 @@ static void starfive_wdt_shutdown(struct platform_device *pdev) > starfive_wdt_pm_stop(&wdt->wdd); > } > > -#ifdef CONFIG_PM_SLEEP > static int starfive_wdt_suspend(struct device *dev) > { > struct starfive_wdt *wdt = dev_get_drvdata(dev); > @@ -556,9 +555,7 @@ static int starfive_wdt_resume(struct device *dev) > > return starfive_wdt_start(wdt); > } > -#endif /* CONFIG_PM_SLEEP */ > > -#ifdef CONFIG_PM > static int starfive_wdt_runtime_suspend(struct device *dev) > { > struct starfive_wdt *wdt = dev_get_drvdata(dev); > @@ -574,11 +571,10 @@ static int starfive_wdt_runtime_resume(struct device *dev) > > return starfive_wdt_enable_clock(wdt); > } > -#endif /* CONFIG_PM */ > > static const struct dev_pm_ops starfive_wdt_pm_ops = { > - SET_RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL) > - SET_SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume) > + RUNTIME_PM_OPS(starfive_wdt_runtime_suspend, starfive_wdt_runtime_resume, NULL) > + SYSTEM_SLEEP_PM_OPS(starfive_wdt_suspend, starfive_wdt_resume) > }; > > static const struct of_device_id starfive_wdt_match[] = { > @@ -594,7 +590,7 @@ static struct platform_driver starfive_wdt_driver = { > .shutdown = starfive_wdt_shutdown, > .driver = { > .name = "starfive-wdt", > - .pm = &starfive_wdt_pm_ops, > + .pm = pm_ptr(&starfive_wdt_pm_ops), > .of_match_table = starfive_wdt_match, > }, > }; Great, Thank you for the improvements. Best regards, Xingyu Wu