On Thu, Oct 29, 2020 at 5:27 PM Lee Jones <lee.jones@xxxxxxxxxx> wrote:Can you elaborate on the pros and cons of each approach? There's
On Thu, 29 Oct 2020, Coiby Xu wrote:
> On Thu, Oct 29, 2020 at 01:00:29PM +0200, Andy Shevchenko wrote:
> > On Thu, Oct 29, 2020 at 06:06:41PM +0800, Coiby Xu wrote:
> > > SIMPLE_DEV_PM_OPS has already took good care of CONFIG_PM_CONFIG.
> >
> > Have you compiled this with
> > % make W=1 ...
> > ?
> >
>
> Sorry my bad. I thought I had run "make modules" with CONFIG_PM_SLEEP
> disabled. I'll run "make W=1 M=..." for each driver after adding
> __maybe_unused in v2.
No, thank you. Just keep it as it is.
The current code is space saving.
Perhaps you need to go thru __maybe_unused handling.
There are pros and cons of each approach, but not above.
> By and large, drivers handle this by using a CONFIG_PM_SLEEP ifdef.
>
> Unless you can make an extremely convincing argument why not to do
> so here, I'd like you to handle it that way instead.
[adding linux-pm to Cc]
The main reason is that everyone gets the #ifdef wrong, I run into
half a dozen new build regressions with linux-next every week on
average, the typical problems being:
- testing CONFIG_PM_SLEEP instead of CONFIG_PM, leading to an unused
function warning
- testing CONFIG_PM instead of CONFIG_PM_SLEEP, leading to a build
failure
- calling a function outside of the #ifdef only from inside an
otherwise correct #ifdef, again leading to an unused function
warning
- causing a warning inside of the #ifdef but only testing if that
is disabled, leading to a problem if the macro is set (this is
rare these days for CONFIG_PM as that is normally enabled)
Using __maybe_unused avoids all of the above.
--
With Best Regards,
Andy Shevchenko