Message ID | 20230705204314.89800-13-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 v5csp2143726vqx; Wed, 5 Jul 2023 14:21:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlHhKN6lFW4rdz1afB0YV2+FQzy0/QXkaoFz2PS8UXbgVtQj3AGMR3C/UpSuRTpy4qwSNOA4 X-Received: by 2002:a05:6a00:2d98:b0:67e:5edd:e6f2 with SMTP id fb24-20020a056a002d9800b0067e5edde6f2mr118499pfb.0.1688592069557; Wed, 05 Jul 2023 14:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688592069; cv=none; d=google.com; s=arc-20160816; b=tvM0cX4UrVaJYk6KMZ4js62Ehpiqt7MhgFWY5NjZZ0knZ2aAW8SKSo9bv3w7e1SjR6 oilLUQqk9/CUqd0nIltufxzSKdTLk0GpOghf5l5zAGc3NsAhsfeJZ/Vl54kAHK2E4iu1 ZqDsgATLNeIpPxMmAq/7sGRhjLa4gunYqkhEA5akSCbyppWU3LuJNTRFhF8vVFg7T+FH mOaIGPqUe3breeqoKqxfTZmuYxzHeeiREVwcJtisGjZ/1Ro7zisEjygsZ6/HI+f6du1d dUKp4WQOFQAAYaLEAZ2oP7kO3Y1wYU0Xh7YbLYH7eSXKhvV8nljtaVFwScjBBB9VzRz7 gA5A== 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=O6riZ7HAoo2pfRWqdmOzvB12VXTYW5f5TYo3Pt2LWIk=; fh=h7isEsjyGfVaKg14U4G9w0MSC8+vXCr26znD1crDC0E=; b=NxO1Q+xE8AMFujc6yGRmMkktckV4RITzIaEKgb2Or+FSCNuv7peVxlYuUw+HTPhVj8 5VI/ehnHXGNga3Xb7HxENAT//OCLcPUTsApxUvbp7sltubEbsdVLEH8x/b3StT+3ewDu hbCJCIONSXHg4D5e9UHO2j8Aqtd7p1DNVEhCOKxzckrTqaMIs6LNWTnB0pgir3ThcGh+ XNEaX+kkgBCxtgV0pDh2rcycKd+qUWbLXOG5hFO3dkp0qfb/r1/jJLWYtsaTk1FmrIda DchTriBZg7R1Vmt/vclMaGLlXXq7d9dbT188oTVKkTiaB7H1bJ5Xb2ZwqffgmYk0bUON /apA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=dqJL0juF; 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 c2-20020a056a00248200b0066871b54e15si15570051pfv.359.2023.07.05.14.20.53; Wed, 05 Jul 2023 14:21:09 -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=dqJL0juF; 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 S233273AbjGEUqr (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 5 Jul 2023 16:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233918AbjGEUqp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 5 Jul 2023 16:46:45 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52BD51FC6; Wed, 5 Jul 2023 13:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1688589825; 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=O6riZ7HAoo2pfRWqdmOzvB12VXTYW5f5TYo3Pt2LWIk=; b=dqJL0juFB6n6IaMEyVkmC5kCzdZ+82vdOx52STzkhs+yMRkdcf/jPHayDbfCyfQL/GIEZp ZkOOG+F9Z2P4nnQVHZOGAyI0VbRXDgtNVvgX0LothzRswXpl31NCDV9N5H3+v2x5kPEkyN IXMYQRCxoTsJx+xzUeyVnEyvnX56Xj0= 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>, Vladimir Zapolskiy <vz@mleia.com>, linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/23] i2c: lpc2k: Remove #ifdef guards for PM related functions Date: Wed, 5 Jul 2023 22:43:03 +0200 Message-Id: <20230705204314.89800-13-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?1770617117740477752?= X-GMAIL-MSGID: =?utf-8?q?1770617117740477752?= |
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.
Note that the behaviour is slightly different than before; the original
code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which
resulted in these functions being compiled in but never used when
CONFIG_PM_SLEEP was disabled.
Now, those functions are only compiled in when CONFIG_PM_SLEEP is
enabled.
Also note that pm_sleep_ptr() has not been applied to each callback
in the dev_pm_ops structure because the pm_sleep_ptr() at the usage site
is sufficient.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
Cc: Vladimir Zapolskiy <vz@mleia.com>
Cc: linux-arm-kernel@lists.infradead.org
---
drivers/i2c/busses/i2c-lpc2k.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
Comments
On Wed, 5 Jul 2023 22:43:03 +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. > > Note that the behaviour is slightly different than before; the original > code wrapped the suspend/resume with #ifdef CONFIG_PM guards, which > resulted in these functions being compiled in but never used when > CONFIG_PM_SLEEP was disabled. > > Now, those functions are only compiled in when CONFIG_PM_SLEEP is > enabled. > > Also note that pm_sleep_ptr() has not been applied to each callback > in the dev_pm_ops structure because the pm_sleep_ptr() at the usage site > is sufficient. > > Signed-off-by: Paul Cercueil <paul@crapouillou.net> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
diff --git a/drivers/i2c/busses/i2c-lpc2k.c b/drivers/i2c/busses/i2c-lpc2k.c index 5c6d96554753..c61157f1409b 100644 --- a/drivers/i2c/busses/i2c-lpc2k.c +++ b/drivers/i2c/busses/i2c-lpc2k.c @@ -431,7 +431,6 @@ static void i2c_lpc2k_remove(struct platform_device *dev) i2c_del_adapter(&i2c->adap); } -#ifdef CONFIG_PM static int i2c_lpc2k_suspend(struct device *dev) { struct lpc2k_i2c *i2c = dev_get_drvdata(dev); @@ -456,11 +455,6 @@ static const struct dev_pm_ops i2c_lpc2k_dev_pm_ops = { .resume_noirq = i2c_lpc2k_resume, }; -#define I2C_LPC2K_DEV_PM_OPS (&i2c_lpc2k_dev_pm_ops) -#else -#define I2C_LPC2K_DEV_PM_OPS NULL -#endif - static const struct of_device_id lpc2k_i2c_match[] = { { .compatible = "nxp,lpc1788-i2c" }, {}, @@ -472,7 +466,7 @@ static struct platform_driver i2c_lpc2k_driver = { .remove_new = i2c_lpc2k_remove, .driver = { .name = "lpc2k-i2c", - .pm = I2C_LPC2K_DEV_PM_OPS, + .pm = pm_sleep_ptr(&i2c_lpc2k_dev_pm_ops), .of_match_table = lpc2k_i2c_match, }, };