All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: ina3221: mark PM functions as __maybe_unused
@ 2018-10-02 21:10 Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2018-10-02 21:10 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck
  Cc: Arnd Bergmann, Nicolin Chen, linux-hwmon, linux-kernel

When CONFIG_PM_SLEEP is disabled, we get a warning about unused
suspend/resume functions:

drivers/hwmon/ina3221.c:451:12: error: 'ina3221_resume' defined but not used [-Werror=unused-function]
 static int ina3221_resume(struct device *dev)
drivers/hwmon/ina3221.c:428:12: error: 'ina3221_suspend' defined but not used [-Werror=unused-function]
 static int ina3221_suspend(struct device *dev)

Picking the correct #ifdef check is hard, so let's remove
that check and instead mark the functions as __maybe_unused
to let the compiler silently drop them instead.

Fixes: 7de1ab9dac8e ("hwmon: (ina3221) Add suspend and resume functions")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/hwmon/ina3221.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
index 1e38b4c43fbf..8c3352910cc4 100644
--- a/drivers/hwmon/ina3221.c
+++ b/drivers/hwmon/ina3221.c
@@ -424,8 +424,7 @@ static int ina3221_probe(struct i2c_client *client,
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int ina3221_suspend(struct device *dev)
+static int __maybe_unused ina3221_suspend(struct device *dev)
 {
 	struct ina3221_data *ina = dev_get_drvdata(dev);
 	int ret;
@@ -448,7 +447,7 @@ static int ina3221_suspend(struct device *dev)
 	return 0;
 }
 
-static int ina3221_resume(struct device *dev)
+static int __maybe_unused ina3221_resume(struct device *dev)
 {
 	struct ina3221_data *ina = dev_get_drvdata(dev);
 	int ret;
@@ -474,7 +473,6 @@ static int ina3221_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops ina3221_pm = {
 	SET_SYSTEM_SLEEP_PM_OPS(ina3221_suspend, ina3221_resume)
-- 
2.18.0

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

* Re: [PATCH] hwmon: ina3221: mark PM functions as __maybe_unused
@ 2018-10-02 21:54 Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2018-10-02 21:54 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Jean Delvare, Nicolin Chen, linux-hwmon, linux-kernel

On Tue, Oct 02, 2018 at 11:10:47PM +0200, Arnd Bergmann wrote:
> When CONFIG_PM_SLEEP is disabled, we get a warning about unused
> suspend/resume functions:
> 
> drivers/hwmon/ina3221.c:451:12: error: 'ina3221_resume' defined but not used [-Werror=unused-function]
>  static int ina3221_resume(struct device *dev)
> drivers/hwmon/ina3221.c:428:12: error: 'ina3221_suspend' defined but not used [-Werror=unused-function]
>  static int ina3221_suspend(struct device *dev)
> 
> Picking the correct #ifdef check is hard, so let's remove
> that check and instead mark the functions as __maybe_unused
> to let the compiler silently drop them instead.
> 
> Fixes: 7de1ab9dac8e ("hwmon: (ina3221) Add suspend and resume functions")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/ina3221.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
> index 1e38b4c43fbf..8c3352910cc4 100644
> --- a/drivers/hwmon/ina3221.c
> +++ b/drivers/hwmon/ina3221.c
> @@ -424,8 +424,7 @@ static int ina3221_probe(struct i2c_client *client,
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
> -static int ina3221_suspend(struct device *dev)
> +static int __maybe_unused ina3221_suspend(struct device *dev)
>  {
>  	struct ina3221_data *ina = dev_get_drvdata(dev);
>  	int ret;
> @@ -448,7 +447,7 @@ static int ina3221_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int ina3221_resume(struct device *dev)
> +static int __maybe_unused ina3221_resume(struct device *dev)
>  {
>  	struct ina3221_data *ina = dev_get_drvdata(dev);
>  	int ret;
> @@ -474,7 +473,6 @@ static int ina3221_resume(struct device *dev)
>  
>  	return 0;
>  }
> -#endif
>  
>  static const struct dev_pm_ops ina3221_pm = {
>  	SET_SYSTEM_SLEEP_PM_OPS(ina3221_suspend, ina3221_resume)
> -- 
> 2.18.0
> 

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

end of thread, other threads:[~2018-10-03  4:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-02 21:10 [PATCH] hwmon: ina3221: mark PM functions as __maybe_unused Arnd Bergmann
2018-10-02 21:54 Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.