lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZKaFRpm9Ito94fgL@smile.fi.intel.com>
Date:   Thu, 6 Jul 2023 12:11:34 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Paul Cercueil <paul@...pouillou.net>
Cc:     Wolfram Sang <wsa@...nel.org>, linux-i2c@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Jan Dabros <jsd@...ihalf.com>
Subject: Re: [PATCH 06/23] i2c: designware: Remove #ifdef guards for PM
 related functions

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@...ux.intel.com>

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

> ---
> Cc: Jarkko Nikula <jarkko.nikula@...ux.intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>
> Cc: Jan Dabros <jsd@...ihalf.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ