Re: [PATCH 1/2] usb: musb: blackfin: fix unused warnings on suspend/resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 19 Dec 2016 14:56:00 -0600
Bin Liu <b-liu@xxxxxx> wrote:

> On Fri, Dec 16, 2016 at 07:19:39PM -0500, Jérémy Lefaure wrote:
> > When CONFIG_PM_SLEEP is disabled, SIMPLE_DEV_PM_OPS does not use
> > bfin_resume and bfin_suspend even if CONFIG_PM is enabled:
> > 
> > drivers/usb/musb/blackfin.c:602:12: warning: ‘bfin_resume’ defined but
> > not used [-Wunused-function]
> >  static int bfin_resume(struct device *dev)
> >             ^~~~~~~~~~~
> > drivers/usb/musb/blackfin.c:585:12: warning: ‘bfin_suspend’ defined but
> > not used [-Wunused-function]
> >  static int bfin_suspend(struct device *dev)
> >             ^~~~~~~~~~~~
> > 
> > The preprocessor condition should be on CONFIG_PM_SLEEP, not on CONFIG_PM.
> > However it is better to mark these functions as __maybe_unused.  
> 
> Based on discussion in [1], __may_be_unused adds unnecessary image size,
> right?
> 
> [1] http://www.spinics.net/lists/linux-usb/msg149994.html
> 
Hi Bin,
I made my own tests and I think that __maybe_unused does not add
unnecessary image size in our case. When I compile with CONFIG_PM_SLEEP
disabled with or without this patch, the sections of both blackfin.o
have the same size (I used with readelf -S).

I think that the compiler discards the unused functions and the
__maybe_unused stuff only tells to the compiler to not raise a warning.

Furthermore, the coding style [1] recommends to use __maybe_unused to
fix this kind of warning.

[1]https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=refs/tags/v4.10-rc1#n1009

Regards,
Jérémy

> Regards,
> -Bin.
> 
> > 
> > Signed-off-by: Jérémy Lefaure <jeremy.lefaure@xxxxxxxxxxxx>
> > ---
> >  drivers/usb/musb/blackfin.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
> > index 310238c6b5cd..f43edc43268b 100644
> > --- a/drivers/usb/musb/blackfin.c
> > +++ b/drivers/usb/musb/blackfin.c
> > @@ -580,8 +580,7 @@ static int bfin_remove(struct platform_device *pdev)
> >  	return 0;
> >  }
> >  
> > -#ifdef CONFIG_PM
> > -static int bfin_suspend(struct device *dev)
> > +static int __maybe_unused bfin_suspend(struct device *dev)
> >  {
> >  	struct bfin_glue	*glue = dev_get_drvdata(dev);
> >  	struct musb		*musb = glue_to_musb(glue);
> > @@ -598,7 +597,7 @@ static int bfin_suspend(struct device *dev)
> >  	return 0;
> >  }
> >  
> > -static int bfin_resume(struct device *dev)
> > +static int __maybe_unused bfin_resume(struct device *dev)
> >  {
> >  	struct bfin_glue	*glue = dev_get_drvdata(dev);
> >  	struct musb		*musb = glue_to_musb(glue);
> > @@ -607,7 +606,6 @@ static int bfin_resume(struct device *dev)
> >  
> >  	return 0;
> >  }
> > -#endif
> >  
> >  static SIMPLE_DEV_PM_OPS(bfin_pm_ops, bfin_suspend, bfin_resume);
> >  
> > -- 
> > 2.11.0
> >   

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux