Skip to contentSkip to conversation

staging: greybus: mark PM functions as __maybe_unused

PATCH In review Arnd Bergmann 3 participants 6 messages May 18, 2017 – May 19, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: mark PM functions as __maybe_unused

Enabling the arche platform for compile testing showed a harmless warning with CONFIG_PM=n:

drivers/staging/greybus/arche-platform.c:632:12: error: 'arche_platform_resume' defined but not used [-Werror=unused-function] drivers/staging/greybus/arche-platform.c:618:12: error: 'arche_platform_suspend' defined but not used [-Werror=unused-function]

This marks the functions as __maybe_unused to shut up the warnings.

Fixes 2eccd4aa19fc ("staging: greybus: enable compile testing of arche driver")
---
 drivers/staging/greybus/arche-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/arche-platform.c +2 -2
index 5bce5e039596..eced2d26467b 100644
@@ -615,7 +615,7 @@ static int arche_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static int arche_platform_suspend(struct device *dev)
+static __maybe_unused int arche_platform_suspend(struct device *dev)
 {
 	/*
 	 * If timing profile premits, we may shutdown bridge
@@ -629,7 +629,7 @@ static int arche_platform_suspend(struct device *dev)
 	return 0;
 }
 
-static int arche_platform_resume(struct device *dev)
+static __maybe_unused int arche_platform_resume(struct device *dev)
 {
 	/*
 	 * Atleast for ES2 we have to meet the delay requirement between
Signature · 1 line
2.9.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

Enabling the arche platform for compile testing showed a harmless warning with CONFIG_PM=n:

drivers/staging/greybus/arche-platform.c:632:12: error: 'arche_platform_resume' defined but not used [-Werror=unused-function] drivers/staging/greybus/arche-platform.c:618:12: error: 'arche_platform_suspend' defined but not used [-Werror=unused-function]

This marks the functions as __maybe_unused to shut up the warnings.

Fixes 2eccd4aa19fc ("staging: greybus: enable compile testing of arche driver")

Thanks for fixing this.

Johan

#2 lore raw
In reply to Arnd Bergmann
Quoted 28 lines · Arnd Bergmann

Enabling the arche platform for compile testing showed a harmless warning with CONFIG_PM=n:

drivers/staging/greybus/arche-platform.c:632:12: error: 'arche_platform_resume' defined but not used [-Werror=unused-function] drivers/staging/greybus/arche-platform.c:618:12: error: 'arche_platform_suspend' defined but not used [-Werror=unused-function]

This marks the functions as __maybe_unused to shut up the warnings.

Fixes 2eccd4aa19fc ("staging: greybus: enable compile testing of arche driver")
---
 drivers/staging/greybus/arche-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/arche-platform.c +1 -1
index 5bce5e039596..eced2d26467b 100644
@@ -615,7 +615,7 @@ static int arche_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static int arche_platform_suspend(struct device *dev)
+static __maybe_unused int arche_platform_suspend(struct device *dev)
 {
 	/*
 	 * If timing profile premits, we may shutdown bridge

drivers/staging/greybus/arche-platform.c static int arche_platform_suspend(struct device *dev) · line 635

Quoted 8 lines
drivers/staging/greybus/arche-platform.c +1 -1
@@ -629,7 +629,7 @@ static int arche_platform_suspend(struct device *dev)
 	return 0;
 }
 
-static int arche_platform_resume(struct device *dev)
+static __maybe_unused int arche_platform_resume(struct device *dev)
 {
 	/*
 	 * Atleast for ES2 we have to meet the delay requirement between

Is __maybe_unused the more preferred way than putting these routines under CONFIG_PM_SLEEP ifdef ?

Signature · 1 line
viresh
#3 lore raw
Quoted 32 lines · Viresh Kumar
Quoted 31 lines · Arnd Bergmann

Enabling the arche platform for compile testing showed a harmless warning with CONFIG_PM=n:

drivers/staging/greybus/arche-platform.c:632:12: error: 'arche_platform_resume' defined but not used [-Werror=unused-function] drivers/staging/greybus/arche-platform.c:618:12: error: 'arche_platform_suspend' defined but not used [-Werror=unused-function]

This marks the functions as __maybe_unused to shut up the warnings.

Fixes 2eccd4aa19fc ("staging: greybus: enable compile testing of arche driver")
---
 drivers/staging/greybus/arche-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/arche-platform.c +1 -1
index 5bce5e039596..eced2d26467b 100644
@@ -615,7 +615,7 @@ static int arche_platform_remove(struct platform_device *pdev)
      return 0;
 }
 
-static int arche_platform_suspend(struct device *dev)
+static __maybe_unused int arche_platform_suspend(struct device *dev)
 {
      /*
       * If timing profile premits, we may shutdown bridge
@@ -629,7 +629,7 @@ static int arche_platform_suspend(struct device *dev)
      return 0;
 }
 
Quoted 8 lines

drivers/staging/greybus/arche-platform.c static int arche_platform_suspend(struct device *dev) · line 635

Quoted 5 lines
drivers/staging/greybus/arche-platform.c +1 -1
-static int arche_platform_resume(struct device *dev)
+static __maybe_unused int arche_platform_resume(struct device *dev)
 {
      /*
       * Atleast for ES2 we have to meet the delay requirement between

Is __maybe_unused the more preferred way than putting these routines under CONFIG_PM_SLEEP ifdef ?

I find that a lot of users get the #ifdef wrong, either using the wrong macro (CONFIG_PM vs CONFIG_PM_SLEEP) or not using the right set of functions (e.g. calling a function only from the suspend handler).

The __maybe_unused annotation avoids both problems and also gives better build time coverage, so that's what I tend to use.

Arnd

Reviewed-by
#4 lore raw
Quoted 6 lines · Arnd Bergmann

I find that a lot of users get the #ifdef wrong, either using the wrong macro (CONFIG_PM vs CONFIG_PM_SLEEP) or not using the right set of functions (e.g. calling a function only from the suspend handler).

The __maybe_unused annotation avoids both problems and also gives better build time coverage, so that's what I tend to use.

Thanks for the explanation Arnd. I hope these unused routines will not be part of the binary that gets generated. Right?

Signature · 1 line
viresh
#5 lore raw
Quoted 10 lines · Viresh Kumar
Quoted 6 lines · Arnd Bergmann

I find that a lot of users get the #ifdef wrong, either using the wrong macro (CONFIG_PM vs CONFIG_PM_SLEEP) or not using the right set of functions (e.g. calling a function only from the suspend handler).

The __maybe_unused annotation avoids both problems and also gives better build time coverage, so that's what I tend to use.

Thanks for the explanation Arnd. I hope these unused routines will not be part of the binary that gets generated. Right?

Correct. Ancient compilers (gcc-4.1) had a bug where a function would still be part of the binary if the only reference to it was from a function pointer that got dropped through dead code elimination, but that is not the case here, and those old compilers are not used in real life any more either.

Arnd