Re: [PATCH] iio: health/afe4403: mark suspend/resume functions __maybe_unused
From: Arnd Bergmann
Date: Mon Feb 15 2016 - 04:21:38 EST
On Monday 15 February 2016 11:18:20 Daniel Baluta wrote:
> On Mon, Feb 15, 2016 at 11:02 AM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> > The newly added afe4403 driver implements suspend/resume using the
> > SIMPLE_DEV_PM_OPS() macro, which leaves out references to the actual
> > functions when CONFIG_PM is disabled, causing a harmless warning:
> >
> > health/afe4403.c:509:12: error: 'afe4403_suspend' defined but not used
> > health/afe4403.c:530:12: error: 'afe4403_resume' defined but not used
> >
> > This marks the functions as __maybe_unused so we don't get those
> > warnings.
> >
> Or we could put _suspend and _resume under CONFIG_PM_SLEEP.
That never works reliably. I still have a backlog of ~50 patches
of drivers that got this wrong in the past.
> We have:
>
> :~/w/iio/drivers/iio$ ack-grep SIMPLE_DEV_PM_OPS | wc -l
> 31
>
> and only 2 drivers using __maybe_unused.
>
> :~/w/iio/drivers/iio$ ack-grep maybe_unused
> gyro/itg3200_core.c
> 354:static int __maybe_unused itg3200_suspend(struct device *dev)
> 365:static int __maybe_unused itg3200_resume(struct device *dev)
>
> adc/imx7d_adc.c
> 553:static int __maybe_unused imx7d_adc_suspend(struct device *dev)
> 566:static int __maybe_unused imx7d_adc_resume(struct device *dev)
>
> For consistency, we should use CONFIG_PM_SLEEP and get rid of __maybe_unused.
I hope to eventually kill off all the CONFIG_PM_SLEEP checks and then
make it work automatically by redefining SIMPLE_DEV_PM_OPS so it
leaves an unused reference to the functions.
Arnd