linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: magn/ak8974: avoid unused function warning
@ 2016-08-26 15:31 Arnd Bergmann
  2016-08-29 13:21 ` Linus Walleij
  2016-08-29 18:55 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-08-26 15:31 UTC (permalink / raw)
  To: Linus Walleij, Jonathan Cameron
  Cc: Arnd Bergmann, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

The ak8974_configure() function is used only from the PM code,
but that can be hidden when CONFIG_PM is disabled:

drivers/iio/magnetometer/ak8974.c:201:12: error: 'ak8974_configure' defined but not used [-Werror=unused-function]

This replaces the #ifdef with a __maybe_unused annotation, which
will work correctly in all configurations and avoid the warning,
as the compiler can now see where ak8974_configure is called from.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 7c94a8b2ee8c ("iio: magn: add a driver for AK8974")
---
 drivers/iio/magnetometer/ak8974.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
index e70e4e22b72c..12bd17b4cf58 100644
--- a/drivers/iio/magnetometer/ak8974.c
+++ b/drivers/iio/magnetometer/ak8974.c
@@ -783,8 +783,7 @@ static int __exit ak8974_remove(struct i2c_client *i2c)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int ak8974_runtime_suspend(struct device *dev)
+static int __maybe_unused ak8974_runtime_suspend(struct device *dev)
 {
 	struct ak8974 *ak8974 =
 		iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
@@ -795,7 +794,7 @@ static int ak8974_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int ak8974_runtime_resume(struct device *dev)
+static int __maybe_unused ak8974_runtime_resume(struct device *dev)
 {
 	struct ak8974 *ak8974 =
 		iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
@@ -822,7 +821,6 @@ out_regulator_disable:
 
 	return ret;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops ak8974_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-- 
2.9.0

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

* Re: [PATCH] iio: magn/ak8974: avoid unused function warning
  2016-08-26 15:31 [PATCH] iio: magn/ak8974: avoid unused function warning Arnd Bergmann
@ 2016-08-29 13:21 ` Linus Walleij
  2016-08-29 18:55 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2016-08-29 13:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

On Fri, Aug 26, 2016 at 5:31 PM, Arnd Bergmann <arnd@arndb.de> wrote:

> The ak8974_configure() function is used only from the PM code,
> but that can be hidden when CONFIG_PM is disabled:
>
> drivers/iio/magnetometer/ak8974.c:201:12: error: 'ak8974_configure' defined but not used [-Werror=unused-function]
>
> This replaces the #ifdef with a __maybe_unused annotation, which
> will work correctly in all configurations and avoid the warning,
> as the compiler can now see where ak8974_configure is called from.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 7c94a8b2ee8c ("iio: magn: add a driver for AK8974")

Nice catch!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] iio: magn/ak8974: avoid unused function warning
  2016-08-26 15:31 [PATCH] iio: magn/ak8974: avoid unused function warning Arnd Bergmann
  2016-08-29 13:21 ` Linus Walleij
@ 2016-08-29 18:55 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-08-29 18:55 UTC (permalink / raw)
  To: Arnd Bergmann, Linus Walleij
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	linux-iio, linux-kernel

On 26/08/16 16:31, Arnd Bergmann wrote:
> The ak8974_configure() function is used only from the PM code,
> but that can be hidden when CONFIG_PM is disabled:
> 
> drivers/iio/magnetometer/ak8974.c:201:12: error: 'ak8974_configure' defined but not used [-Werror=unused-function]
> 
> This replaces the #ifdef with a __maybe_unused annotation, which
> will work correctly in all configurations and avoid the warning,
> as the compiler can now see where ak8974_configure is called from.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 7c94a8b2ee8c ("iio: magn: add a driver for AK8974")
Applied to the togreg branch of iio.git. Will be initially pushed out
as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/magnetometer/ak8974.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
> index e70e4e22b72c..12bd17b4cf58 100644
> --- a/drivers/iio/magnetometer/ak8974.c
> +++ b/drivers/iio/magnetometer/ak8974.c
> @@ -783,8 +783,7 @@ static int __exit ak8974_remove(struct i2c_client *i2c)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM
> -static int ak8974_runtime_suspend(struct device *dev)
> +static int __maybe_unused ak8974_runtime_suspend(struct device *dev)
>  {
>  	struct ak8974 *ak8974 =
>  		iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> @@ -795,7 +794,7 @@ static int ak8974_runtime_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int ak8974_runtime_resume(struct device *dev)
> +static int __maybe_unused ak8974_runtime_resume(struct device *dev)
>  {
>  	struct ak8974 *ak8974 =
>  		iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> @@ -822,7 +821,6 @@ out_regulator_disable:
>  
>  	return ret;
>  }
> -#endif /* CONFIG_PM */
>  
>  static const struct dev_pm_ops ak8974_dev_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> 

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

end of thread, other threads:[~2016-08-29 18:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 15:31 [PATCH] iio: magn/ak8974: avoid unused function warning Arnd Bergmann
2016-08-29 13:21 ` Linus Walleij
2016-08-29 18:55 ` Jonathan Cameron

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).