Skip to contentSkip to conversation

platform/x86: shut up unused-function warning

PATCH Applied Arnd Bergmann 3 participants 4 messages Jan 10, 2017 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: shut up unused-function warning

The newly added driver guards its "resume" callback with an #ifdef CONFIG_PM that should be CONFIG_PM_SLEEP instead, leading to a warning in some configurations:

drivers/platform/x86/surface3-wmi.c:248:12: error: 's3_wmi_resume' defined but not used [-Werror=unused-function]

Using a __maybe_unused annotation without an #ifdef avoids the mistake more reliably.

Fixes 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
---
 drivers/platform/x86/surface3-wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/x86/surface3-wmi.c +1 -3
index cbf4d83a7271..6ac1d1349d7e 100644
@@ -244,13 +244,11 @@ static int s3_wmi_remove(struct platform_device *device)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int s3_wmi_resume(struct device *dev)
+static int __maybe_unused s3_wmi_resume(struct device *dev)
 {
 	s3_wmi_send_lid_state();
 	return 0;
 }
-#endif
 static SIMPLE_DEV_PM_OPS(s3_wmi_pm, NULL, s3_wmi_resume);
 
 static struct platform_driver s3_wmi_driver = {
Signature · 1 line
2.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

The newly added driver guards its "resume" callback with an #ifdef CONFIG_PM that should be CONFIG_PM_SLEEP instead, leading to a warning in some configurations:

drivers/platform/x86/surface3-wmi.c:248:12: error: 's3_wmi_resume' defined but not used [-Werror=unused-function]

Using a __maybe_unused annotation without an #ifdef avoids the mistake more reliably.

Fixes 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")

Ouch. Good catch.

Cheers,
Benjamin

Quoted 26 lines
---
 drivers/platform/x86/surface3-wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/x86/surface3-wmi.c +1 -3
index cbf4d83a7271..6ac1d1349d7e 100644
@@ -244,13 +244,11 @@ static int s3_wmi_remove(struct platform_device *device)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int s3_wmi_resume(struct device *dev)
+static int __maybe_unused s3_wmi_resume(struct device *dev)
 {
 	s3_wmi_send_lid_state();
 	return 0;
 }
-#endif
 static SIMPLE_DEV_PM_OPS(s3_wmi_pm, NULL, s3_wmi_resume);
 
 static struct platform_driver s3_wmi_driver = {
Signature · 1 line
2.9.0
Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

The newly added driver guards its "resume" callback with an #ifdef CONFIG_PM that should be CONFIG_PM_SLEEP instead, leading to a warning in some configurations:

drivers/platform/x86/surface3-wmi.c:248:12: error: 's3_wmi_resume' defined but not used [-Werror=unused-function]

Using a __maybe_unused annotation without an #ifdef avoids the mistake more reliably.

Thanks Arnd,

This appears to be the preferred approach from coding-style.rst 20) Conditional Compilation - we have some cleanup to do in this area I guess.

Queued to next, thanks.

Quoted 30 lines
Fixes 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
---
 drivers/platform/x86/surface3-wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/x86/surface3-wmi.c +1 -3
index cbf4d83a7271..6ac1d1349d7e 100644
@@ -244,13 +244,11 @@ static int s3_wmi_remove(struct platform_device *device)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int s3_wmi_resume(struct device *dev)
+static int __maybe_unused s3_wmi_resume(struct device *dev)
 {
 	s3_wmi_send_lid_state();
 	return 0;
 }
-#endif
 static SIMPLE_DEV_PM_OPS(s3_wmi_pm, NULL, s3_wmi_resume);
 
 static struct platform_driver s3_wmi_driver = {
Signature · 1 line
2.9.0
Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#3 lore raw
Quoted 7 lines · CET Darren Hart

Thanks Arnd,

This appears to be the preferred approach from coding-style.rst 20) Conditional Compilation - we have some cleanup to do in this area I guess.

Queued to next, thanks.

Thanks!

No need to do mass-conversions to __maybe_unused though, Kirtika Ruchandani has started working on a way for the suspend/resume functions to automatically get silently discarded when they are unused, without having an #ifdef or __maybe_unused annotation.

For new code, using __maybe_unused helps avoid this bug though, and the conversion to the future macros would be easy enough.

Arnd