Message ID | 20230705204314.89800-11-paul@crapouillou.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2143745vqx; Wed, 5 Jul 2023 14:21:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHkg0f+rW1aI6TT01rlEI166aQlbPZXTJggwUYQxpEXC5QGw/TdoHt0ld1Kn5L8pD22r/vG X-Received: by 2002:a05:6a20:5481:b0:125:a429:a19c with SMTP id i1-20020a056a20548100b00125a429a19cmr12217pzk.48.1688592071403; Wed, 05 Jul 2023 14:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688592071; cv=none; d=google.com; s=arc-20160816; b=fv1rwaheXPeex7oS7uqZuNyOpTIBZKTxrmARliMzqKh8nkZFDLvAshRmJQfl8xdMpx Y7lMuaOD5hnB6ym2E3/VrJVK5tPb3dBuJKAHir88bkdU4LGRLc4e8wZVT6rAGUORC5VN LJspX6nMQKxgPZfTNAkkBGettJlmOuy7IT5np5yKsev+b3bMPoNOjirJxKwZJ3RXJfzU ZExuGGAm68zWc4kZvAtMeA4pVQwUxu7LdVVAAWLB3RYwWlgwvVfr/VLqZ0SeCgAKreiA kJBAs37BOXF50+drcWhcxHVPmju+kxgaIsUrdozhu7F1jdUB9vcdoehYDhEE/Ac1i0D8 q8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O6s8zlIWAPbRXKFmTmNcemtSW35hNiREJpb3UD0lF9s=; fh=fR5/VcV2ao3Owhxob1GcTDl3VhD8MzLmMkWwK6kQjyw=; b=WITSEe+jDAvDAYnOVPOzEzOOxu3Op1W66yzSH/bgjjHC1RbJb50CyOFZf6v/yHDIfW OTCEs7vkvCgwm5DqYz8ccZU6I+kwfLQLZUdGqqXAOMwezGSGXyW94oWCP3BSVgtPcDrg Z1ZwXIEJedgoPqqE+yUSH52P5GGbjKfGeWTN/AY0r8+K5FPSRh023+qQv/VnHwHjKq16 4yZQOnLXEj4QjIljvQUUWXVl+IW7Z54bXqwnmHTk5bwX1ej0pDgCXpodFpsBDJo/ZIeG iULDnKIKP8D9d41LQKXqcarRhJU066MJrWynHhvqcVntpldElCSkLPrZ0ZcXtwx6WOp7 FvvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=dz3W5Zch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd22-20020a056a002e9600b00682bec0b685si1277257pfb.237.2023.07.05.14.20.53; Wed, 05 Jul 2023 14:21:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=dz3W5Zch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233922AbjGEUqJ (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 5 Jul 2023 16:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbjGEUqF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 5 Jul 2023 16:46:05 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDD91BC2; Wed, 5 Jul 2023 13:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1688589823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O6s8zlIWAPbRXKFmTmNcemtSW35hNiREJpb3UD0lF9s=; b=dz3W5Zchp8vNqFNM5stHka3thaIlMoxDgt46SmsSNtT09+euSUMWOmiofoOMYGrbjMasK2 39/1qvEdvHf4ZhVIKJeDED9YR/2BTL+NhfTOsrG3O90TRpVjsExYBMjiZ+tUwmNalxARMh cz3CAQ8GvVL4EFoGELtkrMWGrypZ4J8= From: Paul Cercueil <paul@crapouillou.net> To: Wolfram Sang <wsa@kernel.org> Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil <paul@crapouillou.net> Subject: [PATCH 10/23] i2c: img-scb: Remove #ifdef guards for PM related functions Date: Wed, 5 Jul 2023 22:43:01 +0200 Message-Id: <20230705204314.89800-11-paul@crapouillou.net> In-Reply-To: <20230705204314.89800-1-paul@crapouillou.net> References: <20230705204314.89800-1-paul@crapouillou.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770617119793396212?= X-GMAIL-MSGID: =?utf-8?q?1770617119793396212?= |
Series |
i2c: Use new PM macros
|
|
Commit Message
Paul Cercueil
July 5, 2023, 8:43 p.m. UTC
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 <paul@crapouillou.net>
---
drivers/i2c/busses/i2c-img-scb.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
Comments
On Wed, 5 Jul 2023 22:43:01 +0200 Paul Cercueil <paul@crapouillou.net> 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 <paul@crapouillou.net> I thought the _DEFINE macros weren't really intended for driver usage and it's good to keep the ability to change those details without updating lots of drivers. Perhaps just express it long hand here? Jonathan > --- > drivers/i2c/busses/i2c-img-scb.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c > index 4b674cfbc6fb..a92e3082542e 100644 > --- a/drivers/i2c/busses/i2c-img-scb.c > +++ b/drivers/i2c/busses/i2c-img-scb.c > @@ -1454,7 +1454,6 @@ static int img_i2c_runtime_resume(struct device *dev) > return 0; > } > > -#ifdef CONFIG_PM_SLEEP > static int img_i2c_suspend(struct device *dev) > { > struct img_i2c *i2c = dev_get_drvdata(dev); > @@ -1482,14 +1481,10 @@ static int img_i2c_resume(struct device *dev) > > return 0; > } > -#endif /* CONFIG_PM_SLEEP */ > > -static const struct dev_pm_ops img_i2c_pm = { > - SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend, > - img_i2c_runtime_resume, > - NULL) > - SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume) > -}; > +static _DEFINE_DEV_PM_OPS(img_i2c_pm, img_i2c_suspend, img_i2c_resume, > + img_i2c_runtime_suspend, img_i2c_runtime_resume, > + NULL); > > static const struct of_device_id img_scb_i2c_match[] = { > { .compatible = "img,scb-i2c" }, > @@ -1501,7 +1496,7 @@ static struct platform_driver img_scb_i2c_driver = { > .driver = { > .name = "img-i2c-scb", > .of_match_table = img_scb_i2c_match, > - .pm = &img_i2c_pm, > + .pm = pm_ptr(&img_i2c_pm), > }, > .probe = img_i2c_probe, > .remove_new = img_i2c_remove,
Hi Jonathan, Le jeudi 06 juillet 2023 à 10:31 +0800, Jonathan Cameron a écrit : > On Wed, 5 Jul 2023 22:43:01 +0200 > Paul Cercueil <paul@crapouillou.net> 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 <paul@crapouillou.net> > I thought the _DEFINE macros weren't really intended for driver > usage and it's good to keep the ability to change those details > without updating lots of drivers. Perhaps just express it long hand > here? Yeah you are right. The "long version" isn't much longer anyway. Cheers, -Paul > Jonathan > > > > --- > > drivers/i2c/busses/i2c-img-scb.c | 13 ++++--------- > > 1 file changed, 4 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-img-scb.c > > b/drivers/i2c/busses/i2c-img-scb.c > > index 4b674cfbc6fb..a92e3082542e 100644 > > --- a/drivers/i2c/busses/i2c-img-scb.c > > +++ b/drivers/i2c/busses/i2c-img-scb.c > > @@ -1454,7 +1454,6 @@ static int img_i2c_runtime_resume(struct > > device *dev) > > return 0; > > } > > > > -#ifdef CONFIG_PM_SLEEP > > static int img_i2c_suspend(struct device *dev) > > { > > struct img_i2c *i2c = dev_get_drvdata(dev); > > @@ -1482,14 +1481,10 @@ static int img_i2c_resume(struct device > > *dev) > > > > return 0; > > } > > -#endif /* CONFIG_PM_SLEEP */ > > > > -static const struct dev_pm_ops img_i2c_pm = { > > - SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend, > > - img_i2c_runtime_resume, > > - NULL) > > - SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume) > > -}; > > +static _DEFINE_DEV_PM_OPS(img_i2c_pm, img_i2c_suspend, > > img_i2c_resume, > > + img_i2c_runtime_suspend, > > img_i2c_runtime_resume, > > + NULL); > > > > static const struct of_device_id img_scb_i2c_match[] = { > > { .compatible = "img,scb-i2c" }, > > @@ -1501,7 +1496,7 @@ static struct platform_driver > > img_scb_i2c_driver = { > > .driver = { > > .name = "img-i2c-scb", > > .of_match_table = img_scb_i2c_match, > > - .pm = &img_i2c_pm, > > + .pm = pm_ptr(&img_i2c_pm), > > }, > > .probe = img_i2c_probe, > > .remove_new = img_i2c_remove, >
diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index 4b674cfbc6fb..a92e3082542e 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c @@ -1454,7 +1454,6 @@ static int img_i2c_runtime_resume(struct device *dev) return 0; } -#ifdef CONFIG_PM_SLEEP static int img_i2c_suspend(struct device *dev) { struct img_i2c *i2c = dev_get_drvdata(dev); @@ -1482,14 +1481,10 @@ static int img_i2c_resume(struct device *dev) return 0; } -#endif /* CONFIG_PM_SLEEP */ -static const struct dev_pm_ops img_i2c_pm = { - SET_RUNTIME_PM_OPS(img_i2c_runtime_suspend, - img_i2c_runtime_resume, - NULL) - SET_SYSTEM_SLEEP_PM_OPS(img_i2c_suspend, img_i2c_resume) -}; +static _DEFINE_DEV_PM_OPS(img_i2c_pm, img_i2c_suspend, img_i2c_resume, + img_i2c_runtime_suspend, img_i2c_runtime_resume, + NULL); static const struct of_device_id img_scb_i2c_match[] = { { .compatible = "img,scb-i2c" }, @@ -1501,7 +1496,7 @@ static struct platform_driver img_scb_i2c_driver = { .driver = { .name = "img-i2c-scb", .of_match_table = img_scb_i2c_match, - .pm = &img_i2c_pm, + .pm = pm_ptr(&img_i2c_pm), }, .probe = img_i2c_probe, .remove_new = img_i2c_remove,