mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
@ 2025-10-14  8:35 Thomas Richard (TI.com)
  2025-10-31  4:11 ` Nishanth Menon
  2025-11-03 15:14 ` Nishanth Menon
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Richard (TI.com) @ 2025-10-14  8:35 UTC (permalink / raw)
  To: Nishanth Menon, Tero Kristo, Santosh Shilimkar
  Cc: Thomas Petazzoni, Gregory CLEMENT, Richard Genoud, Udit Kumar,
	Prasanth Mantena, Abhash Kumar, linux-arm-kernel, linux-kernel,
	Thomas Richard (TI.com)

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)
 {
 	struct ti_sci_info *info = dev_get_drvdata(dev);
 
@@ -3791,12 +3791,10 @@ static void __maybe_unused ti_sci_pm_complete(struct device *dev)
 }
 
 static const struct dev_pm_ops ti_sci_pm_ops = {
-#ifdef CONFIG_PM_SLEEP
-	.suspend = ti_sci_suspend,
-	.suspend_noirq = ti_sci_suspend_noirq,
-	.resume_noirq = ti_sci_resume_noirq,
-	.complete = ti_sci_pm_complete,
-#endif
+	.suspend = pm_sleep_ptr(ti_sci_suspend),
+	.suspend_noirq = pm_sleep_ptr(ti_sci_suspend_noirq),
+	.resume_noirq = pm_sleep_ptr(ti_sci_resume_noirq),
+	.complete = pm_sleep_ptr(ti_sci_pm_complete),
 };
 
 /* Description for K2G */

---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251014-ti-sci-pm-ops-cleanup-1b7ef3f43cbc

Best regards,
-- 
Thomas Richard (TI.com) <thomas.richard@bootlin.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
  2025-10-14  8:35 [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro Thomas Richard (TI.com)
@ 2025-10-31  4:11 ` Nishanth Menon
  2025-10-31  8:33   ` Thomas Richard
  2025-11-03 15:14 ` Nishanth Menon
  1 sibling, 1 reply; 4+ messages in thread
From: Nishanth Menon @ 2025-10-31  4:11 UTC (permalink / raw)
  To: Thomas Richard (TI.com)
  Cc: Tero Kristo, Santosh Shilimkar, Thomas Petazzoni,
	Gregory CLEMENT, Richard Genoud, Udit Kumar, Prasanth Mantena,
	Abhash Kumar, linux-arm-kernel, linux-kernel

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?

>  {
>  	struct ti_sci_info *info = dev_get_drvdata(dev);
>  
> @@ -3791,12 +3791,10 @@ static void __maybe_unused ti_sci_pm_complete(struct device *dev)
>  }
>  
>  static const struct dev_pm_ops ti_sci_pm_ops = {
> -#ifdef CONFIG_PM_SLEEP
> -	.suspend = ti_sci_suspend,
> -	.suspend_noirq = ti_sci_suspend_noirq,
> -	.resume_noirq = ti_sci_resume_noirq,
> -	.complete = ti_sci_pm_complete,
> -#endif
> +	.suspend = pm_sleep_ptr(ti_sci_suspend),
> +	.suspend_noirq = pm_sleep_ptr(ti_sci_suspend_noirq),
> +	.resume_noirq = pm_sleep_ptr(ti_sci_resume_noirq),
> +	.complete = pm_sleep_ptr(ti_sci_pm_complete),
>  };
>  
>  /* Description for K2G */
> 
> ---
> base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
> change-id: 20251014-ti-sci-pm-ops-cleanup-1b7ef3f43cbc
> 
> Best regards,
> -- 
> Thomas Richard (TI.com) <thomas.richard@bootlin.com>
> 

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
  2025-10-31  4:11 ` Nishanth Menon
@ 2025-10-31  8:33   ` Thomas Richard
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Richard @ 2025-10-31  8:33 UTC (permalink / raw)
  To: Nishanth Menon
  Cc: Tero Kristo, Santosh Shilimkar, Thomas Petazzoni,
	Gregory CLEMENT, Richard Genoud, Udit Kumar, Prasanth Mantena,
	Abhash Kumar, linux-arm-kernel, linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
  2025-10-14  8:35 [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro Thomas Richard (TI.com)
  2025-10-31  4:11 ` Nishanth Menon
@ 2025-11-03 15:14 ` Nishanth Menon
  1 sibling, 0 replies; 4+ messages in thread
From: Nishanth Menon @ 2025-11-03 15:14 UTC (permalink / raw)
  To: Tero Kristo, Santosh Shilimkar, Thomas Richard (TI.com)
  Cc: Nishanth Menon, Thomas Petazzoni, Gregory CLEMENT,
	Richard Genoud, Udit Kumar, Prasanth Mantena, Abhash Kumar,
	linux-arm-kernel, linux-kernel

Hi Thomas Richard (TI.com),

On Tue, 14 Oct 2025 10:35:23 +0200, Thomas Richard (TI.com) wrote:
> Using pm_sleep_ptr() macro allows to remove ifdeffery and '__maybe_unused'
> annotations.
> 
> 

I have applied the following to branch ti-drivers-soc-next on [1].
Thank you!

[1/1] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro
      commit: 7a4cd87e76fb4547d7843e3124611bf13004b18b

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent up the chain during
the next merge window (or sooner if it is a relevant bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/ti/linux.git
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-03 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-14  8:35 [PATCH] firmware: ti_sci: replace ifdeffery by pm_sleep_ptr() macro Thomas Richard (TI.com)
2025-10-31  4:11 ` Nishanth Menon
2025-10-31  8:33   ` Thomas Richard
2025-11-03 15:14 ` Nishanth Menon

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®