mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Paul Cercueil <paul@crapouillou.net>
Cc: Wolfram Sang <wsa@kernel.org>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Jan Dabros <jsd@semihalf.com>
Subject: Re: [PATCH 06/23] i2c: designware: Remove #ifdef guards for PM related functions
Date: Thu, 6 Jul 2023 12:11:34 +0300	[thread overview]
Message-ID: <ZKaFRpm9Ito94fgL@smile.fi.intel.com> (raw)
In-Reply-To: <20230705204314.89800-7-paul@crapouillou.net>

On Wed, Jul 05, 2023 at 10:42:57PM +0200, 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.

I have wip of something like this in a private branch, so
I'm glad you beat me up to it!

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

> ---
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Jan Dabros <jsd@semihalf.com>
> ---
>  drivers/i2c/busses/i2c-designware-platdrv.c | 22 ++++++---------------
>  1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 970c1c3b0402..855b698e99c0 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -418,7 +418,6 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
>  	reset_control_assert(dev->rst);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int dw_i2c_plat_prepare(struct device *dev)
>  {
>  	/*
> @@ -429,11 +428,7 @@ static int dw_i2c_plat_prepare(struct device *dev)
>  	 */
>  	return !has_acpi_companion(dev);
>  }
> -#else
> -#define dw_i2c_plat_prepare	NULL
> -#endif
>  
> -#ifdef CONFIG_PM
>  static int dw_i2c_plat_runtime_suspend(struct device *dev)
>  {
>  	struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
> @@ -447,7 +442,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused dw_i2c_plat_suspend(struct device *dev)
> +static int dw_i2c_plat_suspend(struct device *dev)
>  {
>  	struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
>  
> @@ -468,7 +463,7 @@ static int dw_i2c_plat_runtime_resume(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused dw_i2c_plat_resume(struct device *dev)
> +static int dw_i2c_plat_resume(struct device *dev)
>  {
>  	struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
>  
> @@ -479,16 +474,11 @@ static int __maybe_unused dw_i2c_plat_resume(struct device *dev)
>  }
>  
>  static const struct dev_pm_ops dw_i2c_dev_pm_ops = {
> -	.prepare = dw_i2c_plat_prepare,
> -	SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
> -	SET_RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
> +	.prepare = pm_sleep_ptr(dw_i2c_plat_prepare),
> +	LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume)
> +	RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL)
>  };
>  
> -#define DW_I2C_DEV_PMOPS (&dw_i2c_dev_pm_ops)
> -#else
> -#define DW_I2C_DEV_PMOPS NULL
> -#endif
> -
>  /* Work with hotplug and coldplug */
>  MODULE_ALIAS("platform:i2c_designware");
>  
> @@ -499,7 +489,7 @@ static struct platform_driver dw_i2c_driver = {
>  		.name	= "i2c_designware",
>  		.of_match_table = of_match_ptr(dw_i2c_of_match),
>  		.acpi_match_table = ACPI_PTR(dw_i2c_acpi_match),
> -		.pm	= DW_I2C_DEV_PMOPS,
> +		.pm	= pm_ptr(&dw_i2c_dev_pm_ops),
>  	},
>  };
>  
> -- 
> 2.40.1
> 

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2023-07-06  9:11 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 20:42 [PATCH 00/23] i2c: Use new PM macros Paul Cercueil
2023-07-05 20:42 ` [PATCH 01/23] i2c: amd-mp2: Remove #ifdef guards for PM related functions Paul Cercueil
2023-07-06  2:09   ` Jonathan Cameron
2023-07-08  8:42     ` Paul Cercueil
2023-07-05 20:42 ` [PATCH 02/23] i2c: au1550: " Paul Cercueil
2023-07-06  2:10   ` Jonathan Cameron
2023-07-05 20:42 ` [PATCH 03/23] i2c: iproc: " Paul Cercueil
2023-07-06  2:11   ` Jonathan Cameron
2023-07-06 17:01   ` Ray Jui
2023-07-05 20:42 ` [PATCH 04/23] i2c: brcmstb: " Paul Cercueil
2023-07-06  2:12   ` Jonathan Cameron
2023-07-05 20:42 ` [PATCH 05/23] i2c: davinci: " Paul Cercueil
2023-07-06  2:15   ` Jonathan Cameron
2023-07-05 20:42 ` [PATCH 06/23] i2c: designware: " Paul Cercueil
2023-07-06  2:18   ` Jonathan Cameron
2023-07-06  9:11   ` Andy Shevchenko [this message]
2023-07-05 20:42 ` [PATCH 07/23] i2c: exynos5: " Paul Cercueil
2023-07-06  2:25   ` Jonathan Cameron
2023-07-05 20:42 ` [PATCH 08/23] i2c: hix5hd2: " Paul Cercueil
2023-07-06  2:27   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 09/23] i2c: i801: " Paul Cercueil
2023-07-06  2:28   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 10/23] i2c: img-scb: " Paul Cercueil
2023-07-06  2:31   ` Jonathan Cameron
2023-07-08  8:46     ` Paul Cercueil
2023-07-05 20:43 ` [PATCH 11/23] i2c: kempld: " Paul Cercueil
2023-07-06  2:37   ` Jonathan Cameron
2023-07-08  9:13     ` Paul Cercueil
2023-07-05 20:43 ` [PATCH 12/23] i2c: lpc2k: " Paul Cercueil
2023-07-06  2:39   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 13/23] i2c: mt65xx: " Paul Cercueil
2023-07-06  2:40   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 14/23] i2c: nomadik: " Paul Cercueil
2023-07-06  2:41   ` Jonathan Cameron
2023-07-06 17:12   ` Linus Walleij
2023-07-05 20:43 ` [PATCH 15/23] i2c: ocores: " Paul Cercueil
2023-07-06  2:42   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 16/23] i2c: pnx: " Paul Cercueil
2023-07-06  2:49   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 17/23] i2c: pxa: " Paul Cercueil
2023-07-06  2:50   ` Jonathan Cameron
2023-07-05 20:43 ` [PATCH 18/23] i2c: qup: " Paul Cercueil
2023-07-06  2:51   ` Jonathan Cameron
2023-07-05 20:45 ` [PATCH 19/23] i2c: rcar: " Paul Cercueil
2023-07-05 20:45   ` [PATCH 20/23] i2c: s3c2410: " Paul Cercueil
2023-07-06  3:06     ` Jonathan Cameron
2023-07-05 20:45   ` [PATCH 21/23] i2c: sh-mobile: " Paul Cercueil
2023-07-06  3:07     ` Jonathan Cameron
2023-07-10 12:40     ` Geert Uytterhoeven
2023-07-05 20:45   ` [PATCH 22/23] i2c: virtio: " Paul Cercueil
2023-07-06  3:07     ` Jonathan Cameron
2023-07-06  4:27     ` Viresh Kumar
2023-07-05 20:45   ` [PATCH 23/23] i2c: mux: pca954x: " Paul Cercueil
2023-07-06  3:07     ` Jonathan Cameron
2023-07-06  6:31     ` Peter Rosin
2023-07-06  2:52   ` [PATCH 19/23] i2c: rcar: " Jonathan Cameron
2023-07-10 12:41   ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZKaFRpm9Ito94fgL@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=jsd@semihalf.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=paul@crapouillou.net \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®