Re: [tpmdd-devel] [PATCH 3/3] tpm, tpm_crb: runtime power management

From: Jason Gunthorpe
Date: Thu Jun 16 2016 - 16:45:07 EST


On Thu, Jun 16, 2016 at 11:26:48PM +0300, Tomas Winkler wrote:

> > It is compiled out if it is unused. Why would you want to trash the code
> > with #ifdef cages if they are not necessary? I can add /* CONFIG_PM */
> > before the function if that makes it cleaner.
>
> I'm not sure about that, I believe it just suppresses warnings.
> You will need something --gc-sessions int the linker, I'm not sure
> this is used by kernel.

No, it is fine. The compiler drops unused static functions, that is
what the attribute is for. It always does this, so supressing the
warning is the desire behavior. The kernel preference is to avoid
ifdefs and always compile all the code to avoid problems with config
option combinations.

--gc-sections isn't useful unless -ffunction-section is used, which the
kernel doesn't do. Fortunately the dead code is removed by the
compiler, not the linker.

Jason