iio: magn/ak8974: avoid unused function warning
Subsystems (2)
PATCH 1/1 iio: magn/ak8974: avoid unused function warning
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.
--- drivers/iio/magnetometer/ak8974.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/magnetometer/ak8974.c +2 -4
@@ -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,
Signature · 1 line
2.9.0
Quoted 11 lines · Arnd Bergmann
The
ak8974_configure()function is used only from the PM code, but that can be hidden whenCONFIG_PMis 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_unusedannotation, which will work correctly in all configurations and avoid the warning, as the compiler can now see whereak8974_configureis called from.Signed-off-by Arnd Bergmann <[email protected]>Fixes 7c94a8b2ee8c ("iio: magn: add a driver for AK8974")
Nice catch!
Yours,
Linus Walleij
Quoted 11 lines · Arnd Bergmann
The
ak8974_configure()function is used only from the PM code, but that can be hidden whenCONFIG_PMis 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_unusedannotation, which will work correctly in all configurations and avoid the warning, as the compiler can now see whereak8974_configureis called from.Signed-off-by Arnd Bergmann <[email protected]>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
Quoted 36 lines
--- drivers/iio/magnetometer/ak8974.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/iio/magnetometer/ak8974.c +2
-4@@ -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,