Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH] iio: bmi323: Drop CONFIG_PM guards around runtime functions
@ 2024-09-10 17:22 Nathan Chancellor
  2024-09-28 14:23 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2024-09-10 17:22 UTC (permalink / raw)
  To: Jagath Jog J, Jonathan Cameron, Lars-Peter Clausen, Denis Benato
  Cc: linux-iio, llvm, patches, Nathan Chancellor

When building with clang and CONFIG_PM disabled (such as with s390), it
warns:

  drivers/iio/imu/bmi323/bmi323_core.c:121:27: warning: variable 'bmi323_reg_savestate' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    121 | static const unsigned int bmi323_reg_savestate[] = {
        |                           ^~~~~~~~~~~~~~~~~~~~
  drivers/iio/imu/bmi323/bmi323_core.c:133:27: warning: variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    133 | static const unsigned int bmi323_ext_reg_savestate[] = {
        |                           ^~~~~~~~~~~~~~~~~~~~~~~~

These arrays have no references outside of sizeof(), which will be
evaluated at compile time. To avoid these warnings, remove the CONFIG_PM
ifdef guard and use the RUNTIME_PM_OPS macro to ensure these functions
always appear used to the compiler, which allows the references to the
arrays to be visible as well. This results in no difference in runtime
behavior because bmi323_core_pm_ops is only used when CONFIG_PM is set
with the pm_ptr() macro.

Fixes: b09999ee1e86 ("iio: bmi323: suspend and resume triggering on relevant pm operations")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
NOTE: The second warning will still be visible without this change as
well:

https://lore.kernel.org/20240909-iio-bmi323-fix-array-ref-v1-1-51c220f22229@kernel.org/

Technically, the blamed change for that fix is somewhat responsible for
this issue as well but I believe the one I assigned was the real culprit
because this diff should have been in that change.
---
 drivers/iio/imu/bmi323/bmi323_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
index 671401ce80dcf947b7b64ea3af112d2a42ca5501..1d1405d37c5adb2717fc27d6b22540da50dea6d4 100644
--- a/drivers/iio/imu/bmi323/bmi323_core.c
+++ b/drivers/iio/imu/bmi323/bmi323_core.c
@@ -2172,7 +2172,6 @@ int bmi323_core_probe(struct device *dev)
 }
 EXPORT_SYMBOL_NS_GPL(bmi323_core_probe, IIO_BMI323);
 
-#if defined(CONFIG_PM)
 static int bmi323_core_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -2293,11 +2292,9 @@ static int bmi323_core_runtime_resume(struct device *dev)
 	return iio_device_resume_triggering(indio_dev);
 }
 
-#endif
-
 const struct dev_pm_ops bmi323_core_pm_ops = {
-	SET_RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
-			   bmi323_core_runtime_resume, NULL)
+	RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
+		       bmi323_core_runtime_resume, NULL)
 };
 EXPORT_SYMBOL_NS_GPL(bmi323_core_pm_ops, IIO_BMI323);
 

---
base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
change-id: 20240910-iio-bmi323-remove-config_pm-guards-5707958e0ac1

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

* Re: [PATCH] iio: bmi323: Drop CONFIG_PM guards around runtime functions
  2024-09-10 17:22 [PATCH] iio: bmi323: Drop CONFIG_PM guards around runtime functions Nathan Chancellor
@ 2024-09-28 14:23 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-09-28 14:23 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Jagath Jog J, Lars-Peter Clausen, Denis Benato, linux-iio, llvm,
	patches

On Tue, 10 Sep 2024 10:22:54 -0700
Nathan Chancellor <nathan@kernel.org> wrote:

> When building with clang and CONFIG_PM disabled (such as with s390), it
> warns:
> 
>   drivers/iio/imu/bmi323/bmi323_core.c:121:27: warning: variable 'bmi323_reg_savestate' is not needed and will not be emitted [-Wunneeded-internal-declaration]
>     121 | static const unsigned int bmi323_reg_savestate[] = {
>         |                           ^~~~~~~~~~~~~~~~~~~~
>   drivers/iio/imu/bmi323/bmi323_core.c:133:27: warning: variable 'bmi323_ext_reg_savestate' is not needed and will not be emitted [-Wunneeded-internal-declaration]
>     133 | static const unsigned int bmi323_ext_reg_savestate[] = {
>         |                           ^~~~~~~~~~~~~~~~~~~~~~~~
> 
> These arrays have no references outside of sizeof(), which will be
> evaluated at compile time. To avoid these warnings, remove the CONFIG_PM
> ifdef guard and use the RUNTIME_PM_OPS macro to ensure these functions
> always appear used to the compiler, which allows the references to the
> arrays to be visible as well. This results in no difference in runtime
> behavior because bmi323_core_pm_ops is only used when CONFIG_PM is set
> with the pm_ptr() macro.
> 
> Fixes: b09999ee1e86 ("iio: bmi323: suspend and resume triggering on relevant pm operations")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Applied to the fixes togreg branch of iio.git.
I'll rebase that tree on rc1 once available then send a pull request with this
in.

Thanks,

Jonathan

> ---
> NOTE: The second warning will still be visible without this change as
> well:
> 
> https://lore.kernel.org/20240909-iio-bmi323-fix-array-ref-v1-1-51c220f22229@kernel.org/
> 
> Technically, the blamed change for that fix is somewhat responsible for
> this issue as well but I believe the one I assigned was the real culprit
> because this diff should have been in that change.
> ---
>  drivers/iio/imu/bmi323/bmi323_core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/imu/bmi323/bmi323_core.c b/drivers/iio/imu/bmi323/bmi323_core.c
> index 671401ce80dcf947b7b64ea3af112d2a42ca5501..1d1405d37c5adb2717fc27d6b22540da50dea6d4 100644
> --- a/drivers/iio/imu/bmi323/bmi323_core.c
> +++ b/drivers/iio/imu/bmi323/bmi323_core.c
> @@ -2172,7 +2172,6 @@ int bmi323_core_probe(struct device *dev)
>  }
>  EXPORT_SYMBOL_NS_GPL(bmi323_core_probe, IIO_BMI323);
>  
> -#if defined(CONFIG_PM)
>  static int bmi323_core_runtime_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> @@ -2293,11 +2292,9 @@ static int bmi323_core_runtime_resume(struct device *dev)
>  	return iio_device_resume_triggering(indio_dev);
>  }
>  
> -#endif
> -
>  const struct dev_pm_ops bmi323_core_pm_ops = {
> -	SET_RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
> -			   bmi323_core_runtime_resume, NULL)
> +	RUNTIME_PM_OPS(bmi323_core_runtime_suspend,
> +		       bmi323_core_runtime_resume, NULL)
>  };
>  EXPORT_SYMBOL_NS_GPL(bmi323_core_pm_ops, IIO_BMI323);
>  
> 
> ---
> base-commit: 5ba0cb92584ba5e107c97001e09013c1da0772a8
> change-id: 20240910-iio-bmi323-remove-config_pm-guards-5707958e0ac1
> 
> Best regards,


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

end of thread, other threads:[~2024-09-28 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10 17:22 [PATCH] iio: bmi323: Drop CONFIG_PM guards around runtime functions Nathan Chancellor
2024-09-28 14:23 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox