mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Richard <thomas.richard@bootlin.com>
To: Nishanth Menon <nm@ti.com>
Cc: Tero Kristo <kristo@kernel.org>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Gregory CLEMENT <gregory.clement@bootlin.com>,
	Richard Genoud <richard.genoud@bootlin.com>,
	Udit Kumar <u-kumar1@ti.com>, Prasanth Mantena <p-mantena@ti.com>,
	Abhash Kumar <a-kumar2@ti.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
Date: Fri, 31 Oct 2025 09:33:17 +0100	[thread overview]
Message-ID: <da18cd22-9f9e-4166-8a91-d5b19470c693@bootlin.com> (raw)
In-Reply-To: <20251031041131.3qmqfitiertc7vdp@scotch>

Hello Nishanth,

On 10/31/25 5:11 AM, Nishanth Menon wrote:
> On 10:35-20251014, Thomas Richard (TI.com) wrote:
>> Using pm_sleep_ptr() macro allows to remove ifdeffery and '__maybe_unused'
>> annotations.
>>
>> Signed-off-by: Thomas Richard (TI.com) <thomas.richard@bootlin.com>
>> ---
>>  drivers/firmware/ti_sci.c | 18 ++++++++----------
>>  1 file changed, 8 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
>> index 49fd2ae01055d0f425062147422471f0fd49e4bd..99a2e0e2960f463918950fef8829409ec365ce70 100644
>> --- a/drivers/firmware/ti_sci.c
>> +++ b/drivers/firmware/ti_sci.c
>> @@ -3706,7 +3706,7 @@ static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
>>  	}
>>  }
>>  
>> -static int __maybe_unused ti_sci_suspend(struct device *dev)
>> +static int ti_sci_suspend(struct device *dev)
>>  {
>>  	struct ti_sci_info *info = dev_get_drvdata(dev);
>>  	struct device *cpu_dev, *cpu_dev_max = NULL;
>> @@ -3746,7 +3746,7 @@ static int __maybe_unused ti_sci_suspend(struct device *dev)
>>  	return 0;
>>  }
>>  
>> -static int __maybe_unused ti_sci_suspend_noirq(struct device *dev)
>> +static int ti_sci_suspend_noirq(struct device *dev)
>>  {
>>  	struct ti_sci_info *info = dev_get_drvdata(dev);
>>  	int ret = 0;
>> @@ -3758,7 +3758,7 @@ static int __maybe_unused ti_sci_suspend_noirq(struct device *dev)
>>  	return 0;
>>  }
>>  
>> -static int __maybe_unused ti_sci_resume_noirq(struct device *dev)
>> +static int ti_sci_resume_noirq(struct device *dev)
>>  {
>>  	struct ti_sci_info *info = dev_get_drvdata(dev);
>>  	int ret = 0;
>> @@ -3780,7 +3780,7 @@ static int __maybe_unused ti_sci_resume_noirq(struct device *dev)
>>  	return 0;
>>  }
>>  
>> -static void __maybe_unused ti_sci_pm_complete(struct device *dev)
>> +static void ti_sci_pm_complete(struct device *dev)
> 
> PTR_IF when CONFIG_PM_SLEEP is disabled will result in these static
> functions unused, no? should we leave __maybe_unused as is?

PTR_IF is ((cond) ? ptr : NULL)

If CONFIG_PM_SLEEP is disabled, after preprocessor step you will have

	.suspend = 0 ? ti_sci_suspend : NULL,

So ti_sci_suspend() is still used. But as the condition is always false,
the compiler can do some optimization by removing ti_sci_suspend().

PTR_IF macro has a great documentation [1] which describes this use case.

[1]
https://elixir.bootlin.com/linux/v6.17.5/source/include/linux/util_macros.h#L85-L136

Best Regards,
Thomas

  reply	other threads:[~2025-10-31  8:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14  8:35 Thomas Richard (TI.com)
2025-10-31  4:11 ` Nishanth Menon
2025-10-31  8:33   ` Thomas Richard [this message]
2025-11-03 15:14 ` Nishanth Menon

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=da18cd22-9f9e-4166-8a91-d5b19470c693@bootlin.com \
    --to=thomas.richard@bootlin.com \
    --cc=a-kumar2@ti.com \
    --cc=gregory.clement@bootlin.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=p-mantena@ti.com \
    --cc=richard.genoud@bootlin.com \
    --cc=ssantosh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=u-kumar1@ti.com \
    /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

all inboxes | Powered by JetHome®