Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1555620 > unrolled thread

[PATCH] platform/x86: shut up unused-function warning

Started byArnd Bergmann <arnd@arndb.de>
First post2017-01-10 16:30 +0100
Last post2017-01-10 22:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] platform/x86: shut up unused-function warning Arnd Bergmann <arnd@arndb.de> - 2017-01-10 16:30 +0100
    Re: [PATCH] platform/x86: shut up unused-function warning Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-10 16:40 +0100
    Re: [PATCH] platform/x86: shut up unused-function warning Darren Hart <dvhart@infradead.org> - 2017-01-10 21:50 +0100
      Re: [PATCH] platform/x86: shut up unused-function warning Arnd Bergmann <arnd@arndb.de> - 2017-01-10 22:40 +0100

#1555620 — [PATCH] platform/x86: shut up unused-function warning

FromArnd Bergmann <arnd@arndb.de>
Date2017-01-10 16:30 +0100
Subject[PATCH] platform/x86: shut up unused-function warning
Message-ID<sY6x4-32R-49@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1555628

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-10 16:40 +0100
Message-ID<sY6GJ-36e-25@gated-at.bofh.it>
In reply to#1555620
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
> 

[toc] | [prev] | [next] | [standalone]


#1555908

FromDarren Hart <dvhart@infradead.org>
Date2017-01-10 21:50 +0100
Message-ID<sYbwK-5Yo-9@gated-at.bofh.it>
In reply to#1555620
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

[toc] | [prev] | [next] | [standalone]


#1555936

FromArnd Bergmann <arnd@arndb.de>
Date2017-01-10 22:40 +0100
Message-ID<sYcj8-6ul-49@gated-at.bofh.it>
In reply to#1555908
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web