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: <8c0ddc7c-c3e0-f370-3cca-9b6c0ab03e3d@redhat.com>
Date:   Mon, 20 Jun 2022 10:38:34 +0200
From:   Hans de Goede <hdegoede@...hat.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-kernel@...r.kernel.org
Cc:     Andy Shevchenko <andy@...nel.org>, Lee Jones <lee.jones@...aro.org>
Subject: Re: [PATCH v1 2/2] mfd: intel_soc_pmic_chtwc: Switch from
 __maybe_unused to pm_sleep_ptr() etc

Hi,

On 6/16/22 19:10, Andy Shevchenko wrote:
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP support is simpler and less heavier for builds
> than the use of __maybe_unused attributes.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>

I don't see how this helps, __maybe_unused only means the compiler should not
warn AFAIK it is still allowed to remove static globals which are unused
even of they are marked __maybe_unused ?

And DEFINE_SIMPLE_DEV_PM_OPS does not mark the dev_pm_ops as
__maybe_unused where as pm_sleep_ptr() will not reference the struct
when CONFIG_PM is not set.

But I guess that the new PTR_IF magic:

#define PTR_IF(cond, ptr)       ((cond) ? (ptr) : NULL)

Still counts as referencing the struct so we don't get
an unused warning and since cond is a const 0 value the compiler
can optimize things away ?

Regards,

Hans



> ---
>  drivers/mfd/intel_soc_pmic_chtwc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c
> index 1cbe2bcce530..9216f0d34206 100644
> --- a/drivers/mfd/intel_soc_pmic_chtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_chtwc.c
> @@ -222,7 +222,7 @@ static void cht_wc_shutdown(struct i2c_client *client)
>  	disable_irq(pmic->irq);
>  }
>  
> -static int __maybe_unused cht_wc_suspend(struct device *dev)
> +static int cht_wc_suspend(struct device *dev)
>  {
>  	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
>  
> @@ -231,7 +231,7 @@ static int __maybe_unused cht_wc_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused cht_wc_resume(struct device *dev)
> +static int cht_wc_resume(struct device *dev)
>  {
>  	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
>  
> @@ -239,7 +239,7 @@ static int __maybe_unused cht_wc_resume(struct device *dev)
>  
>  	return 0;
>  }
> -static SIMPLE_DEV_PM_OPS(cht_wc_pm_ops, cht_wc_suspend, cht_wc_resume);
> +static DEFINE_SIMPLE_DEV_PM_OPS(cht_wc_pm_ops, cht_wc_suspend, cht_wc_resume);
>  
>  static const struct i2c_device_id cht_wc_i2c_id[] = {
>  	{ }
> @@ -253,7 +253,7 @@ static const struct acpi_device_id cht_wc_acpi_ids[] = {
>  static struct i2c_driver cht_wc_driver = {
>  	.driver	= {
>  		.name	= "CHT Whiskey Cove PMIC",
> -		.pm     = &cht_wc_pm_ops,
> +		.pm     = pm_sleep_ptr(&cht_wc_pm_ops),
>  		.acpi_match_table = cht_wc_acpi_ids,
>  	},
>  	.probe_new = cht_wc_probe,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ