Re: [PATCH] iio: hid-sensors: avoid unused function warning

From: Srinivas Pandruvada
Date: Sun Aug 28 2016 - 17:49:39 EST


On Fri, 2016-08-26 at 17:29 +0200, Arnd Bergmann wrote:
A small rework of the PM code in this driver introduced a harmless
> warning when CONFIG_PM_SLEEP is not set:
>
> drivers/iio/common/hid-sensors/hid-sensor-trigger.c:212:12: error:
> 'hid_sensor_resume' defined but not used [-Werror=unused-function]
>
> This removes the #ifdef and instead marks all three PM functions
> as __maybe_unused, which covers all possible cases and is harder
> to get wrong.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> Fixes: 7f6cf7414538 ("iio: hid-sensors: use asynchronous resume")
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>

> ---
> Âdrivers/iio/common/hid-sensors/hid-sensor-trigger.c | 9 +++------
> Â1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> index 5264ed6e03e5..a3cce3a38300 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> @@ -199,8 +199,7 @@ error_ret:
> Â}
> ÂEXPORT_SYMBOL(hid_sensor_setup_trigger);
> Â
> -#ifdef CONFIG_PM
> -static int hid_sensor_suspend(struct device *dev)
> +static int __maybe_unused hid_sensor_suspend(struct device *dev)
> Â{
> Â struct platform_device *pdev = to_platform_device(dev);
> Â struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> @@ -209,7 +208,7 @@ static int hid_sensor_suspend(struct device *dev)
> Â return _hid_sensor_power_state(attrb, false);
> Â}
> Â
> -static int hid_sensor_resume(struct device *dev)
> +static int __maybe_unused hid_sensor_resume(struct device *dev)
> Â{
> Â struct platform_device *pdev = to_platform_device(dev);
> Â struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> @@ -218,7 +217,7 @@ static int hid_sensor_resume(struct device *dev)
> Â return 0;
> Â}
> Â
> -static int hid_sensor_runtime_resume(struct device *dev)
> +static int __maybe_unused hid_sensor_runtime_resume(struct device
> *dev)
> Â{
> Â struct platform_device *pdev = to_platform_device(dev);
> Â struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> @@ -226,8 +225,6 @@ static int hid_sensor_runtime_resume(struct
> device *dev)
> Â return _hid_sensor_power_state(attrb, true);
> Â}
> Â
> -#endif
> -
> Âconst struct dev_pm_ops hid_sensor_pm_ops = {
> Â SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend,
> hid_sensor_resume)
> Â SET_RUNTIME_PM_OPS(hid_sensor_suspend,