public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: linux-kernel@vger.kernel.org, Andy Shevchenko <andy@kernel.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH v1 2/2] mfd: intel_soc_pmic_chtwc: Switch from __maybe_unused to pm_sleep_ptr() etc
Date: Mon, 20 Jun 2022 12:39:57 +0300	[thread overview]
Message-ID: <YrBAbYsSB3SZPQvt@smile.fi.intel.com> (raw)
In-Reply-To: <8c0ddc7c-c3e0-f370-3cca-9b6c0ab03e3d@redhat.com>

On Mon, Jun 20, 2022 at 10:38:34AM +0200, Hans de Goede wrote:
> 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@linux.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 ?

__maybe_unused will force compiler to compile and linker to drop the section.
The proposed approach saves resources on build, i.e. it's already compiler that
decides not to compile the code.

> 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 ?

See above, it's not olny about warning and compiler.


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-06-20  9:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 17:10 [PATCH v1 1/2] mfd: intel_soc_pmic_chtwc: Use dev_err_probe() Andy Shevchenko
2022-06-16 17:10 ` [PATCH v1 2/2] mfd: intel_soc_pmic_chtwc: Switch from __maybe_unused to pm_sleep_ptr() etc Andy Shevchenko
2022-06-20  8:38   ` Hans de Goede
2022-06-20  9:39     ` Andy Shevchenko [this message]
2022-06-20  8:48   ` Hans de Goede
2022-06-20  9:40     ` Andy Shevchenko
2022-06-27 13:05   ` Lee Jones
2022-06-20  8:33 ` [PATCH v1 1/2] mfd: intel_soc_pmic_chtwc: Use dev_err_probe() Hans de Goede
2022-06-27 13:05 ` Lee Jones

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=YrBAbYsSB3SZPQvt@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.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