linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/x86: shut up unused-function warning
@ 2017-01-10 15:28 Arnd Bergmann
  2017-01-10 15:33 ` Benjamin Tissoires
  2017-01-10 20:41 ` Darren Hart
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-01-10 15:28 UTC (permalink / raw)
  To: Darren Hart
  Cc: Arnd Bergmann, Benjamin Tissoires, Andy Shevchenko,
	platform-driver-x86, linux-kernel

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/platform/x86/surface3-wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
index cbf4d83a7271..6ac1d1349d7e 100644
--- a/drivers/platform/x86/surface3-wmi.c
+++ b/drivers/platform/x86/surface3-wmi.c
@@ -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 = {
-- 
2.9.0

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

* Re: [PATCH] platform/x86: shut up unused-function warning
  2017-01-10 15:28 [PATCH] platform/x86: shut up unused-function warning Arnd Bergmann
@ 2017-01-10 15:33 ` Benjamin Tissoires
  2017-01-10 20:41 ` Darren Hart
  1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Tissoires @ 2017-01-10 15:33 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Darren Hart, Andy Shevchenko, platform-driver-x86, linux-kernel

On Jan 10 2017 or thereabouts, Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Ouch. Good catch.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

> ---
>  drivers/platform/x86/surface3-wmi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
> index cbf4d83a7271..6ac1d1349d7e 100644
> --- a/drivers/platform/x86/surface3-wmi.c
> +++ b/drivers/platform/x86/surface3-wmi.c
> @@ -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 = {
> -- 
> 2.9.0
> 

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

* Re: [PATCH] platform/x86: shut up unused-function warning
  2017-01-10 15:28 [PATCH] platform/x86: shut up unused-function warning Arnd Bergmann
  2017-01-10 15:33 ` Benjamin Tissoires
@ 2017-01-10 20:41 ` Darren Hart
  2017-01-10 21:39   ` Arnd Bergmann
  1 sibling, 1 reply; 4+ messages in thread
From: Darren Hart @ 2017-01-10 20:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Benjamin Tissoires, Andy Shevchenko, platform-driver-x86, linux-kernel

On Tue, Jan 10, 2017 at 04:28:47PM +0100, Arnd Bergmann wrote:
> 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.

> 
> Fixes: 3dda3b3798f9 ("platform/x86: Add custom surface3 platform device for controlling LID")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/platform/x86/surface3-wmi.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
> index cbf4d83a7271..6ac1d1349d7e 100644
> --- a/drivers/platform/x86/surface3-wmi.c
> +++ b/drivers/platform/x86/surface3-wmi.c
> @@ -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 = {
> -- 
> 2.9.0
> 
> 

-- 
Darren Hart
Intel Open Source Technology Center

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

* Re: [PATCH] platform/x86: shut up unused-function warning
  2017-01-10 20:41 ` Darren Hart
@ 2017-01-10 21:39   ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-01-10 21:39 UTC (permalink / raw)
  To: Darren Hart
  Cc: Benjamin Tissoires, Andy Shevchenko, platform-driver-x86, linux-kernel

On Tuesday, January 10, 2017 12:41:17 PM CET Darren Hart wrote:
> 
> 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

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

end of thread, other threads:[~2017-01-10 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10 15:28 [PATCH] platform/x86: shut up unused-function warning Arnd Bergmann
2017-01-10 15:33 ` Benjamin Tissoires
2017-01-10 20:41 ` Darren Hart
2017-01-10 21:39   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).